Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Adding support for "role" attributes for the DocBook reader #10665
base: main
Are you sure you want to change the base?
Adding support for "role" attributes for the DocBook reader #10665
Changes from 8 commits
f361555
193fa21
48f14ee
2ab3c3f
2af15a6
578c9c1
f0827ee
57d61da
007e0c8
f4109d6
17d3ad2
a232161
3703757
06214b6
e104e39
fa815ce
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
why this special case for "emphasis"?
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.
I tried something, which failed, now I need to figure out a way to handle this.
Currently, Pandoc supports
role
attributes for someInlines
. It helps specifyingStrong
,Strikeout
,Underline
andEmph
elements there. All those elements need a wrapper to add attributes to them. But if we try to apply this updated code to:We get:
Which is not what we would want... So my previous attempt in f0827ee was to circumvent this issue, but then no
emphasis
DocBook element would have attributes, which is not what we want either.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.
Oh, right. Well, you're just preventing a role attribute from going on something parsed from an
emphasis
tag, and that's fine given that we already handle the roles in another way.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.
But then, that would mean that we can't have any other
role
value thanbf
,bold
,strong
,strikethrough
, orunderline
, onemphasis
elements ? Maybe in that case the role attributes should be assigned tophrase
elements... That's a compromise I'm willing to make yes, if you feel it makes sense.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.
If other roles are used, then in the part of the code that checks for role on emphasis and gives you Strong, Underline or whatever in response, you could also check for other roles and simply add them as attributes.
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.
From what I understand from the documentation, I think that DocBook documents expect only one
role
attribute per element. To specify more precise roles, it is recommended to parameterize a pattern to do so, but you still only have onerole
attribute.So, knowing this, I think that it shouldn't be possible to have a
role
on aStrong
element, because that would imply that there are necessarily tworole
attributes on the DocBook element, which shouldn't be possible.And in that case, we would only need to change the last line from this part:
Does it make sense like this? 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.
@yanntrividic Not strictly true, docbook would allow multiple tokens in a role attribute, so e.g.
<emphasis role="bold special">
is entirely valid. However, I think that is an extreme edge case and I've never seen it used. I think it would be perfectly fine to only process the known role tokens for emphasis as you describe.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.
I see, you are right... Well I guess it would not be so much work to support this feature, but in that case we would support only one pattern, that is to say, space-separated values for
role
attributes. I think at this point, I would prefer leaving this for a filter to handle.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.
On another note, I've been trying to work on something to discriminate the last case from the others... Not sure how to do it properly though... Here is my attempt: 3703757.
I know there is a parsing error in the code, but as I said, I'm quite new to Haskell, and I am really not sure how I could make this kind of type assertion.
Basically, the thought process here is that if the element is an
emphasis
element, and that has been parsed as anEmph
element, then we can add arole
attribute. But I'm really not sure what would be the right way to check the second condition. Any ideas?Edit: Oops, it is better with this line corrected: 06214b6