Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse div block syntax #327

Closed
ghost opened this issue Mar 18, 2019 · 4 comments
Closed

Parse div block syntax #327

ghost opened this issue Mar 18, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 18, 2019

Pandoc now has a DIV syntax for content blocks. For example:

::: homepage
![logo](images/logo.svg){width=120px height=120px} \

::: content
# Title
## Subtitle

[Contact](mailto:person@domain.com)
:::

:::

Using the latest version of Pandoc, the above produces:

<div class="homepage">
<p><img src="images/logo.svg" alt="logo" width="120" height="120" /><br />
</p>
<div class="content">
<h1>Title</h1>
<h2>Subtitle</h2>
<p><a href="mailto:person@domain.com">Contact</a></p>
</div>
</div>

This would be great to see in FlexMark as well.

@vsch
Copy link
Owner

vsch commented Mar 22, 2019

@DaveJarvis, I will add it to the to do list but at the moment no PanDoc specific profile or extensions are implemented so it may take a while to add this extension along with other PanDoc specific ones.

@ghost
Copy link
Author

ghost commented Mar 4, 2021

Should anybody need this functionality, attached are a few classes that may help.

Here's a short example usage:

final var extensions = new ArrayList<Extension>();
extensions.add( FencedDivExtension.create() );

final IParse parser = Parser.builder().extensions( extensions ).build();
final IRender renderer = HtmlRenderer.builder().extensions( extensions ).build();

This solution works for nested fenced div elements, although it may be suboptimal because the opening and closing div elements are written separately, without knowledge of each other. If a Markdown document is missing the closing ::: then the resulting HTML document will be missing a closing div.

If you have questions, you may be best off asking on StackOverflow.

@ghost ghost closed this as completed Mar 4, 2021
@XenoAmess
Copy link

@DaveJarvis please add a pr...

@ghost
Copy link
Author

ghost commented Aug 22, 2023

@XenoAmess, a PR probably won't happen. If I were to make a flexmark extension at all, it'd be for parsing citations and cross-references, not for fenced DIVs. Here's the latest source code for fenced DIVs as is integrated into my text editor:

https://github.com/DaveJarvis/KeenWrite/tree/main/src/main/java/com/keenwrite/processors/markdown/extensions/fences

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants