the big pre/code/monospace switch

This commit is contained in:
skyanth
2017-02-24 16:47:00 +01:00
parent b5fa8c53b9
commit a43b364fd1
10 changed files with 33 additions and 56 deletions

View File

@@ -14,6 +14,13 @@ The summary table is now ordered on threat level severity and each finding ID in
Generated links (e.g. `<a href="#finding1"/>`) now have an optional attribute `@includepage` which can be set to `yes` or `no` (default is `yes`). If set to `yes`, the link will be generated as it was up till now (e.g. "SID-001 (page 4)"); if set to `no`, the link will be generated without the page number in parenthesis.
###The big pre/code/monospace switch
To have better compatibility with HTML and markdown-to-xml scripts, we have slimmed down and mixed up the `<pre>`, `<code>` and `<monospace>` tags. I tried to describe what was what and is now something else, but it became way too confusing. To keep it simple, just know this:
- `<pre>` is for **terminal output and code blocks**, just like the triple back-tick (```) in markdown
- `<code>` is for the **inline monospace font**, just like the single back-tick (`) in markdown
January 12th, 2017
------------------

View File

@@ -197,7 +197,6 @@ As said, after the title, anything goes (well, almost):
- lists (ordered `<ol>` or unordered `<ul>`)
- tables (`<table>`)
- command input/output boxes (`<pre>`)
- code (`<code>`)
- div containers (`<div>`)
- A section can contain a signing box for the offerte itself (`<generate_offer_signature_box/>`)
- A section can contain a listing of targets, taken from the
@@ -314,7 +313,7 @@ You can use `<div>` as a container for other block elements. This is basically o
#### So what's allowed in `<div>`?
All block elements: `<p>`, `<ul>`, `<ol>`, `<table>`, `<img>`, `<pre>`, `<code>`
All block elements: `<p>`, `<ul>`, `<ol>`, `<table>`, `<img>`, `<pre>`
#### And what elements can *contain* `<div>`?
@@ -491,13 +490,13 @@ Example:
`<p><u>This text is underlined</u> and this text is not.</p>`
**Monospace**
**Monospace/code font**
To have inline text in a monospace font, wrap it in `<monospace>` tags.
To have inline text in a monospace font, wrap it in `<code>` tags.
Example:
`<p><monospace>This text is monospace</monospace> and this text is not.</p>`
`<p><code>This text is monospace</code> and this text is not.</p>`
**Superscript**

View File

@@ -691,7 +691,7 @@ You can use `<div>` as a container for other block elements. This is basically o
#### So what's allowed in `<div>`?
All block elements: `<p>`, `<ul>`, `<ol>`, `<table>`, `<img>`, `<pre>`, `<code>`
All block elements: `<p>`, `<ul>`, `<ol>`, `<table>`, `<img>`, `<pre>`
#### And what elements can *contain* `<div>`?
@@ -870,13 +870,13 @@ Example:
`<p><u>This text is underlined</u> and this text is not.</p>`
**Monospace**
**Monospace/code font**
To have inline text in a monospace font, wrap it in `<monospace>` tags.
To have inline text in a monospace font, wrap it in `<code>` tags.
Example:
`<p><monospace>This text is monospace</monospace> and this text is not.</p>`
`<p><code>This text is monospace</code> and this text is not.</p>`
**Superscript**

View File

@@ -292,15 +292,7 @@
<xs:element name="pre">
<xs:complexType mixed="true">
<xs:choice>
<xs:group ref="inline-except-monospace"/>
<xs:group ref="placeholders"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="code">
<xs:complexType mixed="true">
<xs:choice>
<xs:group ref="inline-except-monospace"/>
<xs:group ref="inline-except-code"/>
<xs:group ref="placeholders"/>
</xs:choice>
</xs:complexType>
@@ -367,10 +359,10 @@
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="monospace">
<xs:element name="code">
<xs:complexType mixed="true">
<xs:choice maxOccurs="unbounded">
<xs:group ref="inline-except-monospace"/>
<xs:group ref="inline-except-code"/>
<xs:group ref="placeholders"/>
</xs:choice>
</xs:complexType>
@@ -499,7 +491,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
@@ -513,7 +505,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
@@ -525,7 +517,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="br"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
@@ -539,7 +531,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="fnref"/>
@@ -552,7 +544,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="fnref"/>
@@ -564,7 +556,7 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="br"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="u"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
@@ -577,14 +569,14 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="br"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="i"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="b"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="monospace"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="code"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sup"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sub"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="bibref"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="fnref"/>
</xs:choice>
</xs:group>
<xs:group name="inline-except-monospace">
<xs:group name="inline-except-code">
<xs:choice>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="a"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="br"/>

View File

@@ -69,7 +69,6 @@
<xs:element ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element name="p" type="block"/>
<xs:element ref="section"/>
<xs:element ref="table"/>
@@ -94,7 +93,6 @@
<xs:choice maxOccurs="unbounded">
<xs:element name="p" type="block"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element ref="table"/>
<xs:element ref="ol"/>
<xs:element ref="ul"/>

View File

@@ -81,7 +81,6 @@
<xs:choice maxOccurs="unbounded">
<xs:element name="p" type="block"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element ref="table"/>
<xs:element ref="ol"/>
<xs:element ref="ul"/>
@@ -150,7 +149,6 @@
<xs:element ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element name="p" type="block"/>
<xs:element ref="section"/>
<xs:element ref="table"/>

View File

@@ -116,7 +116,6 @@
<xs:element ref="generate_testteam"/>
<xs:element name="p" type="block"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element ref="table"/>
<xs:element ref="ol"/>
<xs:element ref="ul"/>
@@ -149,7 +148,6 @@
<xs:element ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element name="p" type="block"/>
<xs:element ref="section"/>
<xs:element ref="table"/>
@@ -201,7 +199,6 @@
<xs:element ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="pre"/>
<xs:element ref="code"/>
<xs:element name="p" type="block"/>
<xs:element ref="table"/>
<xs:element ref="ul"/>
@@ -310,7 +307,6 @@
<xs:element name="img"/>
<xs:element name="table"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
</xs:choice>
</xs:complexType>
</xs:element>
@@ -330,7 +326,6 @@
<xs:element name="img"/>
<xs:element name="table"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
</xs:choice>
</xs:complexType>
</xs:element>
@@ -344,7 +339,6 @@
<xs:element name="img"/>
<xs:element name="table"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
</xs:choice>
</xs:complexType>
</xs:element>
@@ -357,7 +351,6 @@
<xs:element name="img"/>
<xs:element name="table"/>
<xs:element ref="pre"/>
<xs:element ref="code"/>
</xs:choice>
</xs:complexType>
</xs:element>

View File

@@ -50,13 +50,6 @@
</fo:block>
</xsl:template>
<xsl:template match="code">
<fo:block xsl:use-attribute-sets="code">
<xsl:call-template name="checkIfLast"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="div"><!-- div doesn't do anything, it's just there to make snippets more flexible -->
<fo:block>
<xsl:call-template name="checkIfLast"/>

View File

@@ -126,15 +126,15 @@
</fo:inline>
</xsl:template>
<xsl:template match="monospace">
<xsl:template match="code">
<xsl:choose>
<xsl:when test="parent::title">
<fo:inline xsl:use-attribute-sets="monospace-title">
<fo:inline xsl:use-attribute-sets="code-title">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="monospace">
<fo:inline xsl:use-attribute-sets="code">
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>

View File

@@ -37,7 +37,7 @@
<xsl:attribute-set name="TinyFont" use-attribute-sets="DefaultFont">
<xsl:attribute name="font-size">8pt</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="CodeFont" use-attribute-sets="DefaultFont">
<xsl:attribute-set name="PreFont" use-attribute-sets="DefaultFont">
<xsl:attribute name="font-family">LiberationMono</xsl:attribute>
<xsl:attribute name="font-size">10pt</xsl:attribute>
</xsl:attribute-set><!--
@@ -107,12 +107,12 @@
<xsl:attribute-set name="underline">
<xsl:attribute name="text-decoration">underline</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="monospace" use-attribute-sets="DefaultFont">
<xsl:attribute-set name="code" use-attribute-sets="DefaultFont">
<xsl:attribute name="font-family">LiberationMono</xsl:attribute>
<xsl:attribute name="font-size">90%</xsl:attribute>
<xsl:attribute name="background-color">#eeeeee</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="monospace-title" use-attribute-sets="DefaultFont">
<xsl:attribute-set name="code-title" use-attribute-sets="DefaultFont">
<xsl:attribute name="font-family">LiberationMono</xsl:attribute>
<xsl:attribute name="font-size">90%</xsl:attribute>
</xsl:attribute-set>
@@ -149,7 +149,7 @@
<xsl:value-of select="$very-large-space"/>
</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="pre" use-attribute-sets="borders TableFont">
<xsl:attribute-set name="pre" use-attribute-sets="borders PreFont">
<xsl:attribute name="border-style">double</xsl:attribute>
<xsl:attribute name="border-width">2pt</xsl:attribute>
<xsl:attribute name="margin-bottom">
@@ -158,9 +158,6 @@
<xsl:attribute name="white-space-collapse">false</xsl:attribute>
<xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
<xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="code" use-attribute-sets="borders pre">
<xsl:attribute name="font-family">LiberationMono</xsl:attribute>
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="padding">4pt</xsl:attribute>
</xsl:attribute-set>