Outils pour utilisateurs

Outils du site


tips:markdown_vers_pdf_ou_html

Ceci est une ancienne révision du document !


# Convertir du Markdown en PDF ou HTML

<WRAP important> Information

Code non testé, juste posé là en pense bête </WRAP>

Cf NinjaTrappeur sur le canal IRC de PauLLA : ``` { writeScriptBin, bash, lib, pandoc, texlive }:

writeScriptBin “generate-document” '' #!${bash}/bin/bash set -e

export PATH=“${

lib.makeBinPath ( [
  pandoc
  texlive.combined.scheme-medium
])

}” filename=$(basename “$1” | cut -f 1 -d '.') pandoc “$1” -f markdown \

  1. -pdf-engine=xelatex \
  2. o “$filename.pdf” \
  3. V 'geometry:margin=3.25cm' \
  4. V 'lang:en-US' \
  5. V “mainfont:equity_text_b_regular.ttf” \
  6. V 'mainfontoptions:Path=/home/ninjatrappeur/.local/share/fonts/' \
  7. V 'fontsize:11pt'

'' ```

``` Template HTML:

<!DOCTYPE html> <html class=“no-js” lang=“en-US”> <head>

  {{ partial "diary-header.html" . }}
  <title>{{ .Title }}</title>

</head> <body>

site.baseurl

<section id=“main”>

<div id="container" class="h-entry">
  {{ partial "diary-menu.html" }}
<hr/>
<h1 id="article-title" class="p-name">{{ .Title }}</h1>
<div id="article-metadata">
  <a class="u-url black" href="{{ .Permalink }}"><time class="dt-published" datetime="{{ .Date }}">{{ .Date.Format "02/01/2006" }}</time></a>
  <span class="p-category">{{ range .Params.tags }}
    <a href="{{ "tags/" | absURL }}{{ . | urlize }}" class="black">#{{ humanize . }}</a>
    {{ end }}
  </span>
</div>
<hr/>
<div>
      <article id="content" class="e-content">
         {{ .Content }}
      </article>
</div>
<hr/>
{{ partial "diary_subscribe.html" . }}
</div>

</section> partial_diary-footer.html </body>

CSS: @font-face {

  font-family: "Alternativebit Diary";
  src: url('/fonts/Alternativebit_Diary_Regular.woff2') format('woff2'),
       url('/fonts/Alternativebit_Diary_Regular.woff') format('woff'),
       url('/fonts/Alternativebit_Diary_Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;

}

body {

background: white;
color: rgb(51, 51, 51);
font-family: "Alternativebit Diary";
font-size: 1.2em;
text-align: left;
hyphens: auto;

}

a {

color: #ff0c00;
text-decoration: none;

}

a:hover {

background-color: #ff0c00;
color: white;

}

h1, h2, h3, h4{color: black}

img {

display: block;
margin: auto;
border-radius: 5px;
max-width: 100%;

}

blockquote {

border-left: 3px solid #ff0c00;
padding-left: 1em;
background-color: white;
padding-top: .1em;
padding-bottom: .1em;

} /*================= * Header * ===============*/ /* Desktop */ .black {

  color: black;

}

#header {

  margin-bottom: 2em;

}

#entries-title{

  text-align: left;
  margin-top: 0;
  margin-bottom: 0;
  margin-left: .5em;

}

#site-title {

font-size: 10em;
display: flex;
flex-direction: row;
justify-content: center;

}

#site-title > h1 {

margin-top: 0;
margin-bottom: .3em;

}

#links-title > a{

margin: .5em;
font-size: 2vw;

}

@media (min-width: 800px){

  #site-title{font-size: 3em;}
  #links-title > a{font-size:1.9em;}

}

@media (max-width: 800px){

#site-title{font-size: 10}
#links-title > a{font-size:4vw}

} /* All */

#links-title{

display: flex;
flex-direction: row;
justify-content: center;

}

#site-title-text{

  color: black;

}

#site-title-text:hover {

  background: none;
  color: black;

} /*================= * Main * ================ */

#main{

display: flex;
flex-direction: row;
justify-content: center;

}

#container{

font-size: 1em;
background-color: #ffffff;
padding: 2em 5em 2em 5em;

}

/*================= * Adapt to medium * ================ */

/* Computers */ @media (min-width: 1000px){

#container{
  width: 70ch;
}

}

/* Tablets */ @media (min-width: 700px) and (max-width: 1000px){

body {
  font-size: 1em;
}
#container{
  width: 70ch;
}
#site-title {
  font-size: 4em;
}

}

/* Smartphones */ @media (max-width: 700px){

body {
  font-size: 1em;
}
#container {
  width: 95vw;
  padding: .5em;
}
#site-title {
  font-size: 2em;
}

}

/*================= * Post Content * ================*/

/* List */ .post-item{

margin-top: 1em;
display: flex;
flex-direction: row;
justify-content: left;

}

.post-list-link{margin-left: 0.5em}

.post-list-link > a{border-bottom: none}

#article-metadata {

text-align: center;

}

@media (min-width: 800px){ .post-item{font-size: 1em} } /* Content */

hr {

color: black;
border-style: solid;

}

#article-title{

margin: 0;
text-align: center;

}

article>ul>li {margin-bottom: .7em;}

#footer > p {

margin: .35em;

}

#footer{

margin-top: 2em;
font-size:.7em;
display: flex;
flex-direction: column;
align-items: center;

}

code{

white-space: pre-wrap;
background: #f0eeee;
padding: .2em;

} pre {padding:.5em;} /*====================== * Pygments css * * I did not created the pygment monokai css code. * See https://github.com/richleland/pygments-css */ .highlight .hll { background-color: #49483e } .highlight { background: #272822; color: #f8f8f2 } .highlight .c { color: #75715e } /* Comment */ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */ .highlight .k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gi { color: #a6e22e } /* Generic.Inserted */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #white} /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ ```

tips/markdown_vers_pdf_ou_html.1679654729.txt.gz · Dernière modification : de dbroqua