-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Adding support for "role" attributes for the DocBook reader #10665
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
Open
yanntrividic
wants to merge
22
commits into
jgm:main
Choose a base branch
from
yanntrividic:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
f361555
Adding support for "role" attributes for the DocBook reader
yanntrividic 193fa21
Making lines shorter than 80 characters.
yanntrividic 48f14ee
Wrapping elements with role attribute in a Div when needed
yanntrividic 2ab3c3f
Merge branch 'jgm:main' into main
yanntrividic 2af15a6
Modifying the approach following the advice in https://github.com/jgm…
yanntrividic 578c9c1
Merge branch 'jgm:main' into main
yanntrividic f0827ee
When inlines are of type "emphasis", don't add "role" attributes
yanntrividic 57d61da
Merge branch 'main' of https://github.com/yanntrividic/pandoc
yanntrividic 007e0c8
Removing some code to avoid double execution of addPandocAttributes o…
yanntrividic f4109d6
Restoring the code from 2af15a6c425a16b5b59d117f43a6aab71b99f22e rega…
yanntrividic 17d3ad2
Putting back again the discrimination between `emphasis` and other In…
yanntrividic a232161
Wrapping section in Div so that role attributes don't get propagated …
yanntrividic 3703757
Attempt at solving parsing for emphasis elements (see https://github.…
yanntrividic 06214b6
Got things mixed up, function addPandocAttributes added to the return…
yanntrividic e104e39
Removing attempt from 370375728f298a6f00340bb36eb5405214be35bd for a …
yanntrividic fa815ce
Headers were getting the role attributes, now only sections do!
yanntrividic 8a99fb4
Merge branch 'jgm:main' into main
yanntrividic d2135b9
Adding roles to blocks with withOptionalTitle
yanntrividic 04d8b93
Writing tests
yanntrividic 449bb15
Wrong file committed.
yanntrividic 43ac39c
Adding the right tests with docbook-reader.native
yanntrividic a7340bd
Fixing test on headers by adding linebreaks to native file
yanntrividic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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"?
Uh oh!
There was an error while loading. Please reload this page.
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.Uh oh!
There was an error while loading. Please reload this page.
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