mmarkdown / mmark

Mmark: a powerful markdown processor in Go geared towards the IETF
https://mmark.miek.nl
Other
480 stars 45 forks source link

xml: images as artwork doesn't work. #21

Closed miekg closed 5 years ago

miekg commented 6 years ago

for rfc7991 output we can't output images as artwork, as a image element is not an (block)level artwork, this means we must inhibit outputting <t>s, but that is hard. Also using the title for the name attribute looks weird.

A figureblock works, but must be present in the markdown code.

miekg commented 6 years ago

name should probably be the last element of the url or file being referenced.

dericed commented 5 years ago

I'd really like to use this feature. For me, when I include ![alt](img.svg "title") the rendered output in the xml is

<t>
  <artwork src="img.svg" alt="alt" name="title"/>
</t>

which gives an error with xml2rfc 2.12.3

Warning: No 'type' attribute value provided for <artwork>, cannot process source img.svg
Warning: No image data found in source img.svg
Error: Expected ascii-art artwork for <artwork type="">, but found <artwork xmlns:xi="http://www.w3.org/2001/XInclude" src="img.svg" alt="alt" name="title" alig...

but when I remove the alt flag and add a type flag such as <artwork type="svg" name="title" src="img.svg"/> then the xml works in xml2rfc works as expected.

dericed commented 5 years ago

Just wanted to note that piping the mmark output through sed to change the artwork attribute is working for me, such as: mmark test.md | sed 's|alt="alt"|type="svg"|g' > output.xml

However my next issue is that when I convert that output.xml to html with xml2rfc, the first svg looks good but the subsequent ones seem like a malformed version of that svg mixed with the first svg.

dericed commented 5 years ago

Just noting that I have this working without needing to remove the alt attribute. Also I fixed the malformed looking non-first svg issue but ensuring that the id attributes in each svg are unique. So in general, using svg works if type="svg" is added.

miekg commented 5 years ago

ok, but this is just using the HTML fall-through, that works because HTML ~= XML. Good to know though.

SamuelMarks commented 5 years ago

Any progress on this issue?

miekg commented 5 years ago

no, why?

dericed commented 5 years ago

Using svg in the form of ![alt](context.svg "context") works for me; however, I have to:

So by using xmlstarlet to edit the mmark xml output with those two changes, then I can get xml2rfc to render the rfc.

miekg commented 5 years ago

Getting type type from the file and using that doesn't seem too hard to implement.

miekg commented 5 years ago

Ok, having this:

Just take a look at
![alt](context.svg "context")
this image

resuts into this now:

<t>Just take a look at
<artwork src="context.svg" type="alt" name="context"/>
this image</t>

which apart from the <t>s should be good. Stripping those <t> is doable but may only make sense if an image is the only thing in the paragraph? Alternatively a image may surround itself with closing and opening <t>

miekg commented 5 years ago

I think you should just use a subfigure in this case:

Just take a look at

!---
![alt](context.svg "context")
!---

this image

This works and doesn't create the complexities an image creates

miekg commented 5 years ago

update the code and docs to make this work, but you'll still need an subimage.

SamuelMarks commented 5 years ago

Am I missing something? - Using mmark 2.0.45 with xml2rfc 2.22.3. image.md is yours.

$ mmark image.md > imaged.xml
$ xml2rfc --v3 imaged.xml
Parsing file imaged.xml
Converting v2 to v3: imaged.xml
Traceback (most recent call last):
  File "/usr/local/bin/xml2rfc", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/xml2rfc/run.py", line 545, in main
    xmlrfc.tree = v2v3.convert2to3()
  File "/usr/local/lib/python3.7/site-packages/xml2rfc/writers/v2v3.py", line 334, in convert2to3
    func(e, e.getparent())
  File "/usr/local/lib/python3.7/site-packages/xml2rfc/writers/v2v3.py", line 610, in element_rfc
    series = front.xpath('seriesInfo')
AttributeError: 'NoneType' object has no attribute 'xpath

It looks like it's missing the header stuff, seriesInfo and what have you.

miekg commented 5 years ago

[ Quoting notifications@github.com in "Re: [mmarkdown/mmark] xml: images a..." ]

Am I missing something? - Using mmark 2.0.45 with xml2rfc 2.22.3. image.md is yours.

this hasn't been released, you'll need to run it from master. Then still you can't transform a snippet and convert that to text, because xml2rfc expect a whole bunch of meta data.

/Miek

-- Miek Gieben

miekg commented 5 years ago

Merged this, the <t> will be outputted, unless you use a subfigure.