<!--
  - @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
  -
  - @author Julius Härtl <jus@bitgrid.net>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
  -
  -->

<template>
	<div class="settings-markdown" v-html="renderMarkdown" />
</template>

<script>
import { marked } from 'marked'
import dompurify from 'dompurify'

export default {
	name: 'Markdown',
	props: {
		text: {
			type: String,
			default: '',
		},
	},
	computed: {
		renderMarkdown() {
			const renderer = new marked.Renderer()
			renderer.link = function(href, title, text) {
				let prot
				try {
					prot = decodeURIComponent(unescape(href))
						.replace(/[^\w:]/g, '')
						.toLowerCase()
				} catch (e) {
					return ''
				}

				if (prot.indexOf('http:') !== 0 && prot.indexOf('https:') !== 0) {
					return ''
				}

				let out = '<a href="' + href + '" rel="noreferrer noopener"'
				if (title) {
					out += ' title="' + title + '"'
				}
				out += '>' + text + '</a>'
				return out
			}
			renderer.image = function(href, title, text) {
				if (text) {
					return text
				}
				return title
			}
			renderer.blockquote = function(quote) {
				return quote
			}
			return dompurify.sanitize(
				marked(this.text.trim(), {
					renderer,
					gfm: false,
					highlight: false,
					tables: false,
					breaks: false,
					pedantic: false,
					sanitize: true,
					smartLists: true,
					smartypants: false,
				}),
				{
					SAFE_FOR_JQUERY: true,
					ALLOWED_TAGS: [
						'h1',
						'h2',
						'h3',
						'h4',
						'h5',
						'h6',
						'strong',
						'p',
						'a',
						'ul',
						'ol',
						'li',
						'em',
						'del',
						'blockquote',
					],
				}
			)
		},
	},
}
</script>

<style scoped lang="scss">
	.settings-markdown::v-deep {

	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		font-weight: 600;
		line-height: 120%;
		margin-top: 24px;
		margin-bottom: 12px;
		color: var(--color-main-text);
	}

	h1 {
		font-size: 36px;
		margin-top: 48px;
	}

	h2 {
		font-size: 28px;
		margin-top: 48px;
	}

	h3 {
		font-size: 24px;
	}

	h4 {
		font-size: 21px;
	}

	h5 {
		font-size: 17px;
	}

	h6 {
		font-size: var(--default-font-size);
	}

	pre {
		white-space: pre;
		overflow-x: auto;
		background-color: var(--color-background-dark);
		border-radius: var(--border-radius);
		padding: 1em 1.3em;
		margin-bottom: 1em;
	}

	p code {
		background-color: var(--color-background-dark);
		border-radius: var(--border-radius);
		padding: .1em .3em;
	}

	li {
		position: relative;
	}

	ul, ol {
		padding-left: 10px;
		margin-left: 10px;
	}

	ul li {
		list-style-type: disc;
	}

	ul > li > ul > li {
		list-style-type: circle;
	}

	ul > li > ul > li ul li {
		list-style-type: square;
	}

	blockquote {
		padding-left: 1em;
		border-left: 4px solid var(--color-primary-element);
		color: var(--color-text-maxcontrast);
		margin-left: 0;
		margin-right: 0;
	}

	}
</style>
p-0_20_2-maintain'>fop-0_20_2-maintain</option>
<option value='fop-0_90'>fop-0_90</option>
<option value='fop-0_91'>fop-0_91</option>
<option value='fop-0_92'>fop-0_92</option>
<option value='fop-0_93'>fop-0_93</option>
<option value='fop-0_94'>fop-0_94</option>
<option value='fop-0_95'>fop-0_95</option>
<option value='fop-1_0'>fop-1_0</option>
<option value='fop-1_1'>fop-1_1</option>
<option value='fop-1_1old'>fop-1_1old</option>
<option value='fop-1_1rc1'>fop-1_1rc1</option>
<option value='fop-2.6'>fop-2.6</option>
<option value='fop-2_0'>fop-2_0</option>
<option value='fop-2_1'>fop-2_1</option>
<option value='fop-2_10'>fop-2_10</option>
<option value='fop-2_11'>fop-2_11</option>
<option value='fop-2_2'>fop-2_2</option>
<option value='fop-2_3'>fop-2_3</option>
<option value='fop-2_4'>fop-2_4</option>
<option value='fop-2_5'>fop-2_5</option>
<option value='fop-2_6'>fop-2_6</option>
<option value='fop-2_7'>fop-2_7</option>
<option value='fop-2_8'>fop-2_8</option>
<option value='fop-2_9'>fop-2_9</option>
<option value='foray-font'>foray-font</option>
<option value='inlineblock'>inlineblock</option>
<option value='jgoncalves-pdfa-extension-fix'>jgoncalves-pdfa-extension-fix</option>
<option value='main'>main</option>
<option value='maven'>maven</option>
<option value='release-0-13-0'>release-0-13-0</option>
<option value='skynavga/configure-sonar-support'>skynavga/configure-sonar-support</option>
<option value='temp/ssteiner-java23'>temp/ssteiner-java23</option>
<option value='temp/ssteiner-pdfbox3'>temp/ssteiner-pdfbox3</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Apache XML Graphics FOP: https://github.com/apache/xmlgraphics-fop</td><td class='sub right'>www-data</td></tr></table>
<table class='tabs'><tr><td>
<a href='/xmlgraphics-fop.git/about/?h=Temp_PDF_in_PDF'>about</a><a href='/xmlgraphics-fop.git/?h=Temp_PDF_in_PDF'>summary</a><a href='/xmlgraphics-fop.git/refs/?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>refs</a><a href='/xmlgraphics-fop.git/log/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF'>log</a><a class='active' href='/xmlgraphics-fop.git/tree/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>tree</a><a href='/xmlgraphics-fop.git/commit/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>commit</a><a href='/xmlgraphics-fop.git/diff/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>diff</a><a href='/xmlgraphics-fop.git/stats/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF'>stats</a></td><td class='form'><form class='right' method='get' action='/xmlgraphics-fop.git/log/test/xml/pdf-encoding/test-standard-font.fo'>
<input type='hidden' name='h' value='Temp_PDF_in_PDF'/><input type='hidden' name='id' value='21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/xmlgraphics-fop.git/tree/?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>root</a>/<a href='/xmlgraphics-fop.git/tree/test?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>test</a>/<a href='/xmlgraphics-fop.git/tree/test/xml?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>xml</a>/<a href='/xmlgraphics-fop.git/tree/test/xml/pdf-encoding?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>pdf-encoding</a>/<a href='/xmlgraphics-fop.git/tree/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>test-standard-font.fo</a></div><div class='content'>blob: b629eadadb3ac333dc8e3acc9584088e8a80bb73 (<a href='/xmlgraphics-fop.git/plain/test/xml/pdf-encoding/test-standard-font.fo?h=Temp_PDF_in_PDF&amp;id=21e4d157d54a48a555aa0ff7cdab7e3cef707aa5'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
<a id='n26' href='#n26'>26</a>
<a id='n27' href='#n27'>27</a>
<a id='n28' href='#n28'>28</a>
<a id='n29' href='#n29'>29</a>
<a id='n30' href='#n30'>30</a>
<a id='n31' href='#n31'>31</a>
<a id='n32' href='#n32'>32</a>
<a id='n33' href='#n33'>33</a>
<a id='n34' href='#n34'>34</a>
<a id='n35' href='#n35'>35</a>
<a id='n36' href='#n36'>36</a>
<a id='n37' href='#n37'>37</a>
<a id='n38' href='#n38'>38</a>
</pre></td>
<td class='lines'><pre><code>