8000 DocBook reader: add support for citerefentry by jtojnar · Pull Request #7433 · jgm/pandoc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DocBook reader: add support for citerefentry #7433

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

Closed
wants to merge 1 commit into from

Conversation

jtojnar
Copy link
Contributor
@jtojnar jtojnar commented Jul 8, 2021

For referencing UNIX manual pages https://docbook.org/tdg/en/html-ng/citerefentry.html

@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 8, 2021

I could also add support for converting this AST back to DocBook.

And support for rST syntax: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage

@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 8, 2021

Actually, rST parses as {"t":"Code","c":[["",["interpreted-text"],[["role","manpage"]]],"ls(1)"]} so it might make sense to parse DocBook as that too and we would get rST reader/writer support for free.

Edit: Done that.

@jtojnar jtojnar force-pushed the docbook-citeref branch from fc6b489 to 6224c89 Compare July 8, 2021 21:03
@jgm
Copy link
Owner
jgm commented Jul 9, 2021

Is this element specific to man pages? That certainly isn't clear from the documentation.

@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 9, 2021

As far as I was able to tell, it was originally intended for referring to UNIX manual pages, either part of the same DocBook document as refentry element, or external – hence the manvolnum element:

The notion of a volume number is historical. UNIX manual pages (“man pages”), for which refentry was devised, were typically stored in three-ring binders. Each bound manual was a volume in a set and contained information about a particular class of things. For example, volume 1 was for user commands, and volume 8 was for administrator commands.

These days, refentry is more general, for example the linked element documentation pages are each a refentry.

As per the Processing expectations section of citerefentry, the element is supposed to be a hyperlink to a refentry (when in the same document) but pandoc does not support refentry tag at the moment so that is moot.


But I do not see much of a difference between reference and manual pages so it makes sense to me to use role=manpage. Especially since this will likely cover the vast majority of uses.

@jgm
Copy link
Owner
jgm commented Jul 9, 2021

Thanks for the info. Somehow it doesn't seem right to me to emit such a rST-specific AST element. Nothing else in he DocBook reader parses into something with class interpreted-text. I'd rather have something more abstract that can be manipulated. Perhaps

<citerefentry><refentrytitle>nix.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>

could become

Code ("",["citerefentry"],[]) "nix.conf(5)"

unless it's important to be able to access the volume number as an attribute.

@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 9, 2021

Yeah, that’s what I had at the start but I liked being able to unify stuff. But I guess we can keep it distinct and use Lua filter when converting between from DocBook to rST.

function Code(elem)
  elem.classes = elem.classes:map(function (x)
    if x == 'citerefentry' then
      elem.attributes['role'] = 'manpage'
      return 'interpreted-text'
    else
      return x
    end
  end)

  return elem
end

I considered keeping the manvolnum as an attribute but it should be easy to parse it out if someone needs it.

Originally intended for referring to UNIX manual pages, either part of the same DocBook document as refentry element, or external – hence the manvolnum element.
These days, refentry is more general, for example the element documentation pages linked below are each a refentry.

As per the *Processing expectations* section of citerefentry, the element is supposed to be a hyperlink to a refentry (when in the same document) but pandoc does not support refentry tag at the moment so that is moot.

https://tdg.docbook.org/tdg/5.1/citerefentry.html
https://tdg.docbook.org/tdg/5.1/manvolnum.html
https://tdg.docbook.org/tdg/5.1/refentry.html

For greater interoperability, the produced AST matches rST syntax:

https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage

That is intended for manual pages but I do not see much of a difference between reference and manual pages so it makes sense to me to use role=manpage. Especially since this will likely cover the vast majority of uses.
@jtojnar jtojnar force-pushed the docbook-citeref branch from 6224c89 to afd196f Compare July 9, 2021 19:50
@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 9, 2021

It would be nice if pandoc could preserve semantics between formats that support it but yeah, these special classes are not very nice representation.

Opened #7437 where it produces Code with just .citerefentry class.

@jtojnar
Copy link
Contributor Author
jtojnar commented Jul 12, 2021

Resolved in #7437.

@jtojnar jtojnar closed this Jul 12, 2021
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

Successfully merging this pull request may close these issues.

2 participants
0