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

[Question] After stripping of MARKER_BLOCKQUOTE in tokenization, could we add back MARKER_BLOCKQUOTE when the line/block is finished? #238

Open
DivineDominion opened this issue Feb 19, 2022 · 1 comment

Comments

@DivineDominion
Copy link
Contributor

Another fringe question from me about using libMMD for highlighting :)

TL;DR: What were the observations before you implemented strip_quote_markers_from_block? Could there be another way to solve the problem while retaining the MARKER_BLOCKQUOTE token?

Motivation

For list items, it's trivial to apply a different style to e.g. MARKER_LIST_BULLET. Same with MARKER_H1--MARKER_H6 for headings. This can be useful to apply a less vibrant color to visually "demote" Markdown syntax markers and thus let the real content "pop" more.

Observation

I noticed that MARKER_BLOCKQUOTE is removed from the token tree, though. Looking at the code, it appears the reason for the removal is that this helps with "recursion", i.e. multi-level quotations:

/// Strip leading blockquote markers and non-indent space
/// (for recursively parsing blockquotes)
void strip_quote_markers_from_block(mmd_engine * e, token * block) {

I don't yet follow why this stripping was needed, and what'd happen without it. If you remember and could spare the time to explain real quick, that'd be great.

What I'd like to achieve when I understand the problem better

Given that this is technically necessary to do what libMMD does at the moment, I don't want to change that -- it'd be great though if a MARKER_BLOCKQUOTE would be added back as a post-fix when recursive blockquote parsing is finished. Leave stripping in, but then add it back after whatever the stripping was used for has been completed.

The parser seems to be the best place to apply this because the 'state' ("we're currently parsing a blockquote") is available already.

By now I'm pretty sure that you'll tell me to check the string for > at the beginning of a BLOCK_BLOCKQUOTE instead when consuming the token tree, @fletcher :) And yes, that works of course. But it'd be so much nicer if the MARKER_* tokens were available consistently. Then one didn't have to parse the beginning of the string again to restore the information/the state that the parser already had.

@DivineDominion DivineDominion changed the title [Question] Could stripping of MARKER_BLOCKQUOTE in tokenization add back MARKER_BLOCKQUOTE for the whole line in the end? [Question] After stripping of MARKER_BLOCKQUOTE in tokenization, could we add back MARKER_BLOCKQUOTE when the line/block is finished? Feb 19, 2022
@fletcher
Copy link
Owner

fletcher commented Feb 19, 2022 via email

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

No branches or pull requests

2 participants