Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pandoc-beamer-block:
- classes: [info]
- classes: [alert]
type: alert
title: Danger
~~~

The metadata block above is used to add a `block` environment around
Expand All @@ -31,6 +32,7 @@ Each entry of `pandoc-beamer-block` is a YAML dictionary containing:
transformation will be applied. This parameter is mandatory.
* `type`: the block type (either `alert`, `example`, `info`, `theorem`,
`proof`, `corollary`, `definition`, `lemma` and `fact`)
* `title`: an optional default title to use

## Example

Expand Down
3 changes: 2 additions & 1 deletion src/pandoc_beamer_block/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def prepare(doc: Doc):
):
definition["classes"] = frozenset(definition["classes"])
definition["type"] = definition.get("type", "info")
definition["title"] = definition.get("title", "")
doc.defined.append(definition)


Expand Down Expand Up @@ -110,7 +111,7 @@ def block(elem: Element, doc: Doc) -> list[Element] | None:
output_format="latex",
)
else:
title = ""
title = definition["title"]

if definition["type"] == "alert":
return latex(elem, "alertblock", title)
Expand Down
23 changes: 23 additions & 0 deletions tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def test_title_complex(self):
---
pandoc-beamer-block:
- classes: ['class1', 'class2']
title: Ignored
---
::: {.class1 .class2 title="**My Title**"}
:::
Expand All @@ -141,3 +142,25 @@ def test_title_complex(self):
)
self.assertIn("\\begin{block}{\\textbf{My Title}}", text)
self.assertIn("\\end{block}", text)

def test_title_default(self):
doc = BlockTest.conversion(
"""
---
pandoc-beamer-block:
- classes: ['class1']
title: My Title
---
::: class1 :::
:::
""",
"beamer",
)
text = convert_text(
doc,
input_format="panflute",
output_format="latex",
extra_args=["--wrap=none"],
)
self.assertIn("\\begin{block}{My Title}", text)
self.assertIn("\\end{block}", text)
Loading