Skip to content

Commit

Permalink
feat: Attach XML source to PDF file
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara committed Jan 31, 2024
1 parent 4d4255e commit 5311ace
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions xml2rfc/writers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
default_options.__dict__ = {
'accept_prepped': None,
'add_xinclude': None,
'attach_xml': False,
'allow_local_file_access': False,
'basename': None,
'bom': False,
Expand Down
4 changes: 4 additions & 0 deletions xml2rfc/writers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ def render_rfc(self, h, x):

add.link(head, None, href=self.xmlrfc.source, rel='alternate', type='application/rfc+xml')

if self.options.attach_xml:
# add attachment for PDF
add.link(head, None, href=self.xmlrfc.source, rel='attachment', type='application/xml', title='Source')

# 6.3.5. Link to License
#
# The <head> element contains a <link> tag, with "rel" attribute of
Expand Down
2 changes: 1 addition & 1 deletion xml2rfc/writers/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import_error = e
weasyprint = False


import xml2rfc
from xml2rfc.writers.base import default_options, BaseV3Writer
from xml2rfc.writers.html import HtmlWriter
Expand Down Expand Up @@ -77,6 +76,7 @@ def pdf(self):
self.options.no_css = True
self.options.image_svg = True
self.options.pdf = True
self.options.attach_xml = True
htmlwriter = HtmlWriter(self.xmlrfc, quiet=True, options=self.options, date=self.date)
html = htmlwriter.html()

Expand Down

0 comments on commit 5311ace

Please sign in to comment.