d0c-s4vage / lookatme

An interactive, terminal-based markdown presenter
https://lookatme.readthedocs.io/en/latest/
MIT License
2.06k stars 59 forks source link

Codeblocks now have line numbers, highlighting, bg override #189

Closed d0c-s4vage closed 1 year ago

d0c-s4vage commented 1 year ago

Adds the ability to enable line numbers in code blocks and highlight lines

Specifically:

See #164 See #89

d0c-s4vage commented 1 year ago

From this markdown:

---
theme: dark
styles:
  slides:
    fg: "#c0c08f"
  code:
    style: monokai
    inline_lang: python
    bg_override: "#302030"
---

The `a = 100 * "hello"` metadata that can be prefixed in slides includes these top level
fields:

```python {.numberLines startFrom="1" hllines=1,5,7-9 .nobackground}
def hello():
    """Text
    """
    # comment
    print("Hello world")
    print("Hello world")
    a = 1 * 20 + 30
    X = 1 * 20 + 30
    y = 1 * 20 + 30
    a = 1 * 20 + 30
    k = 1 * 20 + 30
```

You get this:

image

d0c-s4vage commented 1 year ago

Note: this PR includes breaking changes to how syntax highlighting styles are defined:

styles:
  code:
    style: zenburn
    inline_lang: python
    bg_override: "#aabbcc"