-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Markdown reader: allow more attributes in special spans #7307
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
Conversation
|
I'm having second thoughts about this change, so I'm putting it here as a PR. |
36872a4 to
e0e7eb9
Compare
|
I think this makes sense, but why require that the special class be the first one? |
|
My thought here was that it might give the best balance between new functionality and unintended conversions. I wouldn't be too surprised to see |
e0e7eb9 to
455e36c
Compare
|
I've added a second commit (intended to be squashed) that removes the limitation of expecting the special class as the first, allowing it to occur in any position. |
455e36c to
78c9bf1
Compare
|
I really don't know what's best here. Your concern about people wanting to use a span with class |
|
Maybe we should just keep the current behavior and document the behavior as intentional? Or, but that's a bit of a stretch, we could hide the new behavior behind the I note that neither the |
|
I don't think I'd want to remove the current behavior for |
|
Note that in a recent commit 649133f Maybe I'll take out the documentation for |
See #7307. Motivation: there is talk of removing this.
I believe the Pandoc-flavored Markdown Writer still outputs pandoc/src/Text/Pandoc/Writers/Markdown/Inline.hs Lines 304 to 317 in 407de98
(Speaking of the inconsistent output of Underline between Pandoc-flavored Markdown and the other Markdown flavors, this could be a good opportunity to decide/discuss whether "raw HTML" like |
|
So, the suggestion is to parse |
9f1621c to
9619f6b
Compare
|
The second commit in this PR removes the limitation of the special class (like smallcaps) having to be the first class, making it possible to use markup like |
9619f6b to
32f66cb
Compare
src/Text/Pandoc/Readers/Markdown.hs
Outdated
| return $ case smallCapsAttr attr of | ||
| Just ("", [], []) -> B.smallcaps <$> lab | ||
| Just scAttr -> B.spanWith scAttr . B.smallcaps <$> lab | ||
| Nothing -> case underlineAttr attr of | ||
| Just ("", [], []) -> B.underline <$> lab | ||
| Just ulAttr -> B.spanWith ulAttr . B.underline <$> lab | ||
| Nothing -> B.spanWith attr <$> lab | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, to be consistent with the recent change to the HTML writer, we should allow [test]{.underline .smallcaps} to turn into Underline [SmallCaps [Str "test"]]? Not sure, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done fairly elegantly with a fold over the classes, similarly to what I did in the HTML writer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Done.
Spans with "smallcaps" as the first class are converted to *SmallCaps* elements. While previously no other classes or attributes were allowed, additional classes, attributes, and an identifier are not permitted and kept in a *SmallCaps* wrapping *Span* element. The same change is applied to underline spans, where the first class must be either "ul" or "underline". Closes: jgm#4102
32f66cb to
40a8418
Compare
Spans with "smallcaps" as the first class are converted to SmallCaps
elements. While previously no other classes or attributes were allowed,
additional classes, attributes, and an identifier are not permitted and
kept in a SmallCaps wrapping Span element.
The same change is applied to underline spans, where the first class
must be either "ul" or "underline".
Closes: #4102