Skip to content

Commit

Permalink
Remove xml2 renderer (#97)
Browse files Browse the repository at this point in the history
RFC 7749 is deprecated, remove renderer, assorted test files and
documentation. The -2 switch is removed as well, making this a breaking
change for folks depending on it.

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg authored Oct 10, 2019
1 parent a3cfbe4 commit e6b11f0
Show file tree
Hide file tree
Showing 47 changed files with 14 additions and 1,531 deletions.
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ write RFC using Markdown.

It provides an advanced markdown dialect that processes file(s) to produce internet-drafts in XML
[RFC 7991](https://tools.ietf.org/html/rfc7991) format. Mmark can produce xml2rfc (aforementioned
RFC 7991), RFC 7749 (xml2rfc version 2), HTML5 output, markdown and manual pages.
RFC 7991), RFC 7749 (xml2rfc version 2 - now deprecated), HTML5 output, markdown and manual pages.

Example RFCs in Mmark format can be [found in the Github
repository](https://github.com/mmarkdown/mmark/tree/master/rfc).
Expand Down Expand Up @@ -74,14 +74,8 @@ Making a draft in text form (v3 output)
% ./mmark rfc/3514.md > x.xml
% xml2rfc --v3 --text x.xml

Making a draft in text form (v2 output)

% ./mmark -2 rfc/3514.md > x.xml
% xml2rfc --text x.xml

Outputting HTML5 is done with the `-html` switch. Outputting RFC 7749 is done with `-2`. And
outputting markdown is done with the `-markdown` switch (optionally you can use `-width` to set the
text width).
Outputting HTML5 is done with the `-html` switch. Outputting markdown is done with the `-markdown`
switch (optionally you can use `-width` to set the text width).

[1]: https://daringfireball.net/projects/markdown/ "Markdown"
[2]: https://golang.org/ "Go Language"
Expand All @@ -96,12 +90,6 @@ cd rfc
make txt
~~~

For v2 (i.e. the current (2018) way of making RFC), just run:
~~~ sh
cd rfc
make TWO="yes" txt
~~~

Official RFCs are in rfc/orig (so you can compare the text output from mmark).

## Using Mmark as a library
Expand Down
55 changes: 5 additions & 50 deletions Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Biggest changes:

It fixes a bunch of long standing bugs and the parser generates an abstract syntax tree (AST). It
will be easier to add new renderers with this setup. It is also closer to Common Mark. So we took
this opportunity to support RFC 7991 XML (xml2rfc version 3), HTML5, RFC 7749 XML (xml2rfc
version 2) and Markdown output (use mmark is a markdown formatter). Also with code upstreamed (to
[gomarkdown](https://github.com/gomarkdown)), we have less code to maintain.
this opportunity to support RFC 7991 XML (xml2rfc version 3), HTML5, RFC 7749 XML (xml2rfc version 2
- now deprecated) and Markdown output (use mmark is a markdown formatter). Also with code upstreamed
(to [gomarkdown](https://github.com/gomarkdown)), we have less code to maintain.

Because of the abstract syntax tree it will also be easier to write helper tools, like, for instance
a tool that checks if all referenced labels in the document are actually defined. Another idea could
Expand Down Expand Up @@ -185,50 +185,7 @@ Comments:
### XML RFC 7749 Output

When the RFC editor drops support for this format it will be removed from Mmark as well. This is
expected to happen in 2019.

Title Block:
: Identical to RFC 7991, Mmark will take care to translate this into something xml2rfc (v2) can
understand. An Mmark document will generate valid RFC 7991 and 7749 XML, unless [block
level attributes](#block-level-attributes) are used that are speficic to each format.
*Area* defaults to "Internet" and *Ipr* defaults to `trust200902`.

Not giving a date will output `<date/>` which mean the current date will be applied *when
xml2rfc is run*.

BCP 14/RFC 2119 Keywords:
: If an RFC 2119 word is found enclosed in `**` it will be rendered normally i.e. `**MUST**`
becomes `MUST`.

Artwork/Source code:
: There is no such distinction so these will be rendered in the same way regardless. If you need a
caption you can just give it one. If you want the *final* output to prefix `Figure N` or `Table
N` is **also** needs to have an anchor; this is done with a block level attribute: `{#figX}`. If
you *only* want `Figure N`, only give it an anchor.

Block Level Attributes:
: We use the attributes as specified in RFC 7749, e.g. to speficify an empty list style use:
`{style="empty"}` before the list. Any attributes that are not allowed are filtered out, so
`{style="empty" empty="true"}`, will make a document both RFC 7749 and RFC 7991 compliant.

Asides:
: Basically not supported, will be rendered as a plain paragraph.

Footnotes:
: Are discarded from the final output, don't use them.

Images:
: Images are not supported and we fake an artwork with some of the meta date. Using the example from
RFC 7991 output would just yields: `<artwork>img.jpg "alt" "title"</artwork>`.

Block quote:
: Supported by faking an list with style empty.

Horizontal Line:
: Outputs a paragraph with 60 dashes `-`.

Comments:
: HTML comments are detected and discarded.
expected to happen in 2019. This has been implemented in October 2019.

### HTML5 Output

Expand Down Expand Up @@ -632,9 +589,7 @@ detected by Mmark.
### BCP14

Phrases that are defined in RFC 2119 (i.e. MUST, SHOULD, etc) are detected when being type set as
strong elements: `**MUST**`, in the RFC 7991 output these will typeset as `<bcp14>MUST</bcp14>`. In
RFC 7749 output it will just be `MUST`. Not that these can't span lines, e.g., `**MUST NOT**`, must
be on a single line.
strong elements: `**MUST**`, in the RFC 7991 output these will typeset as `<bcp14>MUST</bcp14>`.

# Changes from version 1

Expand Down
21 changes: 6 additions & 15 deletions mmark.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 'MMARK(1)'
author:
- Mmark Authors
date: February 2019
date: October 2019
---

# NAME
Expand All @@ -20,7 +20,7 @@ is, however, *also* suited for writing complete books and other technical docume

Mmark provides an advanced markdown dialect that processes file(s) to produce internet-drafts in XML
[RFC 7991](https://tools.ietf.org/html/rfc7991) format. Mmark can produce xml2rfc (aforementioned
RFC 7991), RFC 7749 (xml2rfc version 2), HTML5, manual pages and markdown output.
RFC 7991), HTML5, manual pages and markdown output.

The syntax is detailed at [https://mmark.miek.nl/syntax](https://mmark.miek.nl/syntax).

Expand Down Expand Up @@ -56,15 +56,9 @@ Compared to other markdown variants mmark adds:

* BCP14 (RFC 2119) keyword detection.

## RFC 7749

This is currently the XML format used by the RFC editor for accepting Internet-Drafts. Some of these
turn into RFCs. For getting text output you'll need xml2rfc for the actual conversion.

## RFC 7991

This is the future XML format used by the RFC editor for accepting Internet-Drafts. A valid markdown
document can be turned in RFC 7749 or RFC 7991 XML.
This is the XML format used by the RFC editor for accepting Internet-Drafts.

## HTML5

Expand Down Expand Up @@ -101,10 +95,6 @@ The man renderer outputs nroff that can be viewed via man(1).

: create HTML output.

**-2**

: generate RFC 7749 XML.

**-markdown**

: output (normalized) markdown.
Expand Down Expand Up @@ -141,5 +131,6 @@ The man renderer outputs nroff that can be viewed via man(1).

# ALSO SEE

RFC 7991 and RFC 7749. The main site for Mmark is [https://mmark.miek.nl](https://mmark.miek.nl). The syntax
used by mmark is explained in the [syntax page](https://mmark.miek.nl/post/syntax/).
RFC 7991 and (maybe) RFC 7749. The main site for Mmark is
[https://mmark.miek.nl](https://mmark.miek.nl). The syntax used by mmark is explained in the [syntax
page](https://mmark.miek.nl/post/syntax/).
12 changes: 0 additions & 12 deletions mmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
mmarkout "github.com/mmarkdown/mmark/render/markdown"
"github.com/mmarkdown/mmark/render/mhtml"
"github.com/mmarkdown/mmark/render/xml"
"github.com/mmarkdown/mmark/render/xml2"
)

var (
Expand All @@ -29,7 +28,6 @@ var (
flagFragment = flag.Bool("fragment", false, "don't create a full document")
flagHTML = flag.Bool("html", false, "create HTML output")
flagIndex = flag.Bool("index", true, "generate an index at the end of the document")
flagTwo = flag.Bool("2", false, "generate RFC 7749 XML")
flagMarkdown = flag.Bool("markdown", false, "generate markdown (experimental)")
flagMan = flag.Bool("man", false, "generate manual pages (nroff)")
flagWrite = flag.Bool("w", false, "write to source file when generating markdown")
Expand Down Expand Up @@ -150,16 +148,6 @@ func main() {
}

renderer = html.NewRenderer(opts)
case *flagTwo:
opts := xml2.RendererOptions{
Flags: xml2.CommonFlags,
Comments: [][]byte{[]byte("//"), []byte("#")},
}
if *flagFragment {
opts.Flags |= xml2.XMLFragment
}

renderer = xml2.NewRenderer(opts)
case *flagMarkdown:
opts := mmarkout.RendererOptions{TextWidth: *flagWidth}
renderer = mmarkout.NewRenderer(opts)
Expand Down
25 changes: 0 additions & 25 deletions mmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/gomarkdown/markdown/parser"
"github.com/mmarkdown/mmark/mparser"
"github.com/mmarkdown/mmark/render/xml"
"github.com/mmarkdown/mmark/render/xml2"
)

func TestMmarkXML(t *testing.T) {
Expand All @@ -37,30 +36,6 @@ func TestMmarkXML(t *testing.T) {
}
}

func TestMmarkXML2(t *testing.T) {
dir := "testdata/2"
testFiles, err := ioutil.ReadDir(dir)
if err != nil {
t.Fatalf("could not read %s: %q", dir, err)
}
for _, f := range testFiles {
if f.IsDir() {
continue
}

if filepath.Ext(f.Name()) != ".md" {
continue
}
base := f.Name()[:len(f.Name())-3]
opts := xml2.RendererOptions{
Flags: xml2.CommonFlags | xml2.XMLFragment,
}
renderer := xml2.NewRenderer(opts)

doTest(t, dir, base, renderer)
}
}

func doTest(t *testing.T, dir, basename string, renderer markdown.Renderer) {
filename := filepath.Join(dir, basename+".md")
input, err := ioutil.ReadFile(filename)
Expand Down
66 changes: 0 additions & 66 deletions render/xml2/bibliography.go

This file was deleted.

Loading

0 comments on commit e6b11f0

Please sign in to comment.