Skip to content
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

ODF Header metadata field escapes XML characters and inserts data into wrong position #225

Open
AmberHaelo opened this issue Aug 14, 2021 · 0 comments

Comments

@AmberHaelo
Copy link

Version: MultiMarkdown 6 v6.6.0
Problem Description: In attempting to insert a custom paragraph style into a document's FODT header, I found that the ODF Header metadata field, which is described in the documentation as being useful for such tasks, produces a result that cannot be validly inserted into the file, because all of the XML characters within the metadata value field are escaped, and the string is injected into a place that greatly reduces its utility.

Input

Title: Test ODF Header Insertion
ODF Header:
	<office:styles>
		<style:style style:name="Scene_20_Break" style:display-name="Scene Break" style:family="paragraph" style:parent-style-name="Standard">
			<style:paragraph-properties fo:margin-left="0pt" fo:margin-right="0pt" fo:margin-top="15.59pt" fo:margin-bottom="15.59pt" style:contextual-spacing="false" fo:text-align="center" style:justify-single-word="false" fo:text-indent="0pt" style:auto-text-indent="false"/>
		</style:style>
	</office:styles>

# Sample Document #

Whik gronk; thung epp rintax whik jince...

Output (Excerpt)

<office:meta>
	<dc:title>Test ODF Header Insertion</dc:title>
	<dc:creator>AmberHaelo</dc:creator>
	<meta:user-defined meta:name="customfield">If all we can do is insert XML into the office:meta element, we might as well just use custom metadata fields.</meta:user-defined>
&lt;office:styles&gt; &lt;style:style style:name=&quot;Scene_20_Break&quot; style:display-name=&quot;Scene Break&quot; style:family=&quot;paragraph&quot; style:parent-style-name=&quot;Standard&quot;&gt; &lt;style:paragraph-properties fo:margin-left=&quot;0pt&quot; fo:margin-right=&quot;0pt&quot; fo:margin-top=&quot;15.59pt&quot; fo:margin-bottom=&quot;15.59pt&quot; style:contextual-spacing=&quot;false&quot; fo:text-align=&quot;center&quot; style:justify-single-word=&quot;false&quot; fo:text-indent=&quot;0pt&quot; style:auto-text-indent=&quot;false&quot;/&gt; &lt;/style:style&gt; &lt;/office:styles&gt;</office:meta>

Expected Output (Excerpt)

<office:meta>
	<dc:title>Test ODF Header Insertion</dc:title>
	<dc:creator>AmberHaelo</dc:creator>
	<meta:user-defined meta:name="customfield">If all we can do is insert XML into the office:meta element, we might as well just use custom metadata fields.</meta:user-defined>
</office:meta>
<office:styles>
	<style:style style:name="Scene_20_Break" style:display-name="Scene Break" style:family="paragraph" style:parent-style-name="Standard">
		<style:paragraph-properties fo:margin-left="0pt" fo:margin-right="0pt" fo:margin-top="15.59pt" fo:margin-bottom="15.59pt" style:contextual-spacing="false" fo:text-align="center" style:justify-single-word="false" fo:text-indent="0pt" style:auto-text-indent="false"/>
	</style:style>
</office:styles>

As noted in the sample text itself, the other problem with the output is that the field string is inserted directly into the office:meta element. This limits the usefulness of the ODF Header metadata field to inserting metadata, as I understand it, which we might as well do using the native support for adding custom fields.

I thus suggest that to resolve the current lack of utility with this field, the following two changes be made:

  • [BUG] XML escaping should be disabled for the value of the ODF Header field. As the MMD documentation notes, it is up to the user to make the string XML valid. It is as far as I can tell impossible to get around this problem currently.
  • [SUGGESTION] Move the insertion point of the string to occupy the line break following </office:meta>, so that the user is free to inject whatever form of document header material they desire. If they really wish to insert more metadata then it is a simple matter to re-open the element (as we demonstrate here, by re-opening the office:styles element---a practice that seems to work fine in my testing.
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

No branches or pull requests

1 participant