Tharollo e seng e entsoe ea markdown2pdf e nang le khoutu ea mohloli bakeng sa Linux

Tlhaloso

Markdown ke mokhoa o motle oa ho ngola sengoloa se sekhuts'oane, 'me ka linako tse ling se na le mongolo o mongata, o nang le mokhoa o bonolo oa mongolo o tšekaletseng le o hlakileng. Markdown e boetse e loketse ho ngola lingoliloeng tse nang le khoutu ea mohloli e kenyellelitsoeng. Empa ka linako tse ling u batla ho tants'a ka moropa ka moropa ho e fihlela faele ea kamehla ea PDF e hlophisitsoeng hantle, le hore ho se be le mathata nakong ea phetoho, eo, ka mohlala, ke neng ke e-na le eona - u ke ke ua ngola ka Serussia ka Serussia. maikutlo a khoutu ea mohloli, mela e telele haholo ha e fetisetsoe, empa ho khaola le mathata a mang a manyane. Taelo e tla u lumella ho theha converter kapele md2pdf ntle le ho utloisisa hantle hore na e sebetsa joang. Sengoliloeng sa ho instola ka boiketsetso ho feta kapa ka tlase se ka tlase karolong e nepahetseng.

Template ea ka ea mohlala ea TeX bakeng sa phetoho e sebelisa sephutheloana sa fonte sa PSCyr, se kenyelletsang tšehetso bakeng sa lifonti tsa Microsoft, e leng. Times New Roman. Ho ne ho e-na le litlhoko tse joalo bakeng sa diploma ho ea ka GOST. Haeba u tseba, u ka fetola template hore e lumellane le litlhoko tsa hau. Ka litaelo tsa ka, u tla tlameha ho qala ka ho thetsa ka tlhophiso ea PSCyr ho TexLive. Setupo se etsoa kabong ea Linux Mint Mate, bakeng sa lipehelo tse ling u kanna ua tlameha ho google lifoldara tse tloaelehileng tsa sephutheloana sa TexLive bakeng sa sistimi ea hau.

Ho kenya TexLive

Ha e le hantle, o ka kenya feela likarolo tse hlokahalang tsa sephutheloana sena. Empa ka bonna, ka 'nete ke ne ke le botsoa haholo ho batla bonyane bo hlokahalang ho kenya tšebetsong. Ho etsa bonnete ba hore tsohle lia sebetsa, kenya sephutheloana kaofela sa TexLive. E bitsoa textlive-tletseng 'me e boima ho feta 2 gigabytes, hopola taba ena. Re etsa taelo:

user@hostname:~$ sudo apt install texlive-full -y

Ka mor'a ho kenya nako e telele ka ho lekaneng, u ka tsoela pele ho ntho e latelang.

Ho kenya Pandoc Converter

Pandoc ke sephutheloana sa Linux se u lumellang hore u fetole liforomo tse ling tsa mongolo ho tse ling. E na le likarolo tse ngata tse khahlisang tseo u ka iphumanang u le Inthaneteng. Re thahasella feela monyetla oa ho fetolela file ea "markdown" ho PDF. Sheba hore na Pandoc e kentsoe 'me haeba ho se joalo, e kenye. Ka mohlala, joalo ka:

user@hostname:~$ dpkg -s pandoc

Haeba tlhahiso e re ha e ea kengoa, kenya:

user@hostname:~$ sudo apt install pandoc -y

Ho kenya sephutheloana sa PSCyr bakeng sa TexLive

Pele o hloka ho jarolla PSCyr. Hajoale e ntse e fumaneha ho sena kgokahanyo, haeba ka nako ea ho bala sehlooho se sa fumanehe ka lebaka le itseng, u se ke ua nyahama, ho bonolo ho se fumana hammoho le litaelo tsa ho kenya ka ho thapa ntho e kang "Ho kenya PsCyr texlive" ho Google. Haeba e fumaneha, joale ho bonolo ho uena, e jarolle, 'me re tla nahana hore u notlollotse polokelo ka har'a foldara ea lapeng, ka hona, tsela e eang foldareng e ka har'a polokelo e shebahala joalo. ~/PSCyr. Ebe u ea ho Terminal 'me u phethe litaelo tse latelang ka tatellano:

user@hostname:~$ cd
user@hostname:~$ mkdir ./PSCyr/fonts/map ./PSCyr/fonts/enc
user@hostname:~$ cp ./PSCyr/dvips/pscyr/*.map ./PSCyr/fonts/map/
user@hostname:~$ cp ./PSCyr/dvips/pscyr/*.enc ./PSCyr/fonts/enc/
user@hostname:~$ echo "fadr6t AdvertisementPSCyr "T2AEncoding ReEncodeFont"" > ./PSCyr/fonts/map/pscyr.map

Ka mor'a moo, fumana moo buka ea sebaka seo e leng teng textmf. Re etsa taelo:

user@hostname:~$ kpsewhich -expand-var='$TEXMFLOCAL'

Mohlomong u na le bukana ena - /usr/local/share/textmf/, ebe re etsa:

user@hostname:~$ sudo cp -R ./PSCyr/* /usr/local/share/texmf/

Ho lokile, kapa o ka se khathatsehe mme o tsamaise taelo e tla kopitsa foldareng textmf hohle moo a leng teng:

user@hostname:~$ sudo cp -R ./PSCyr/* $(kpsewhich -expand-var='$TEXMFLOCAL')

Mehala ea PSCyr e kentsoe, hokela ho TexLive:

user@hostname:~$ sudo texhash
user@hostname:~$ updmap --enable Map=pscyr.map
user@hostname:~$ sudo mktexlsr

Setšoantšo sa LaTeX bakeng sa phetoho ea md2pdf

Nke ke ka hlalosa hantle hore na template ena e hlophisitsoe joang, 'me ke tla e fa feela tlas'a mohatelli ntle le tlhaloso e ngata. Ho lekane ho bolela hore e hlophisitsoe hantle, bonyane ho latela hore na e sebetsana joang le litemana tse nang le khoutu e ngata ea mohloli. Haeba u sa khotsofala ke boholo ba li-indents, sebaka sa mela, ho haella ha linomoro le likaroloana, ka maikutlo a ka ho bonolo haholo ho google potso Inthaneteng "ho etsa joang ka Latex ..." le ebe tlhoko ya hao. Haeba e sa hlake ho hang, ngola litlhalosong, ke tla leka ho itlhahloba lilemong tse 4 tse fetileng mme ke hlalose hore na ke mohala ofe oa template o ikarabellang bakeng sa eng. Khabareng, ke tla ngola hore na ke e entse joang ho PC ea ka, 'me u lokolohile ho e pheta kapa ho e fetola.

Etsa faele template.tex lenaneng /usr/share/texlive/:

user@hostname:~$ sudo touch /usr/share/texlive/template.tex

E fe tumello ea ho bala:

user@hostname:~$ sudo chmod 444 /usr/share/texlive/template.tex

e bule tlas'a motso 'me u kenye litaba tse patiloeng tlas'a spoiler ka tlase ho eona:

user@hostname:~$ sudo nano /usr/share/texlive/template.tex

Likahare tsa template /usr/share/texlive/template.tex

documentclass[oneside,final,14pt]{extreport}
usepackage{extsizes}
usepackage{pscyr}
renewcommand{rmdefault}{ftm}
usepackage[T2A]{fontenc}
usepackage[utf8]{inputenc}
usepackage{amsmath}
usepackage{mathtext}
usepackage{multirow}
usepackage{listings}
usepackage{ucs}
usepackage{hhline}
usepackage{tabularx}
usepackage{booktabs}
usepackage{longtable}
usepackage{titlesec}
usepackage{hyperref}
usepackage{graphicx}
usepackage{setspace}
usepackage[center,it,labelsep=period]{caption}
usepackage[english,russian,ukrainian]{babel}
usepackage{vmargin}
newcommand{specialcell}[2][c]{%
    begin{tabular}[#1]{@{}c@{}}#2end{tabular}}
setpapersize{A4}
setmarginsrb {1cm}{1cm}{1cm}{1cm}{0pt}{0mm}{0pt}{13mm}
usepackage{indentfirst}
setlengthparindent{1cm}
renewcommand{baselinestretch}{1}
renewcommandthechapter{}
renewcommandthesection{}
renewcommandthesubsection{}
renewcommandthesubsubsection{}
titleformat
{chapter} % command
{bfseriesnormalsizecentering} % format
{thechapter} % label
{0.5ex} % sep
{
    centering
}
[
vspace{-1.5ex}
] % after-code
titleformat
{section}
[block]
{normalfontbfseries}
{thesection}{0.5em}{}
sloppy
letoldenumerateenumerate
renewcommand{enumerate}{
  oldenumerate
  setlength{itemsep}{1pt}
  setlength{parskip}{0pt}
  setlength{parsep}{0pt}
}
letolditemizeitemize
renewcommand{itemize}{
  olditemize
  setlength{itemsep}{1pt}
  setlength{parskip}{0pt}
  setlength{parsep}{0pt}
}
providecommand{tightlist}{%
  setlength{itemsep}{0pt}setlength{parskip}{0pt}}

titlespacing{subsubsection}{parindent}{3mm}{3mm}
titlespacing{subsection}{parindent}{3mm}{3mm}
usepackage{color}

lstset{
    basicstyle=footnotesizettfamily,
    inputencoding=utf8,
    extendedchars=true,
    showspaces=false,
    keepspaces=true
    showstringspaces=false,
    showtabs=false,
    tabsize=4,
    captionpos=b,
    breaklines=true,
    breakatwhitespace=true,
    breakautoindent=true,
    linewidth=textwidth
}

begin{document}
$if(title)$
maketitle
$endif$
$if(abstract)$
begin{abstract}
$abstract$
end{abstract}
$endif$

$for(include-before)$
$include-before$

$endfor$
$if(toc)$
{
$if(colorlinks)$
hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$}
$endif$
setcounter{tocdepth}{$toc-depth$}
tableofcontents
}
$endif$
$if(lot)$
listoftables
$endif$
$if(lof)$
listoffigures
$endif$
$body$

$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(book-class)$
renewcommandbibname{$biblio-title$}
$else$
renewcommandrefname{$biblio-title$}
$endif$
$endif$
bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}

$endif$
$endif$
$if(biblatex)$
printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$

$endif$
$for(include-after)$
$include-after$

$endfor$
end{document}

Ho boloka faele /usr/share/texlive/template.tex mme o ngole mongolo o tla fetolela faele ya Makrdown ho PDF, o bopa foldareng e le nngwe faele e bitswang faele ya Markdown e nang le sehlongwapele .pdf, ke hore, kamora ho sokoloha. filename.md e tla hlaha foldareng. filename.md.pdf. Ha re bitse script md2pdf le ho kena tseleng / usr / bin. Ha re phethiseng litaelo ka tatellano:

user@hostname:~$ cd
user@hostname:~$ touch md2pdf
user@hostname:~$ echo "#!/bin/bash" > md2pdf
user@hostname:~$ echo "pandoc --output=$1.pdf --from=markdown_github --latex-engine=pdflatex --listings --template=/usr/share/texlive/template.tex $1" >> md2pdf
user@hostname:~$ sudo cp md2pdf /usr/bin/
user@hostname:~$ sudo chmod 111 /usr/bin/md2pdf

Mola oa 4 ehlile o na le taelo ea ho sokoloha. ela hloko --ho tloha=markdown_github. Mofuta oa GitHub oa Markdown o ka morao o lumellana le Markdown ea mantlha, kahoo haeba mongolo oa hau o ngotsoe ho eona, ha ua tlameha ho tšoenyeha. Haeba faele ea hau ea MD e ngotsoe ka puo e itseng ea Markdown, bala buka ea Pandoc (man pandoc), etsa bonnete ba hore ts'ebetsong ea hau e tšehetsoa ke eona, 'me u fetole /usr/bin/md2pdf ha ho hlokahala.

Script bakeng sa ho instola ho feta kapa ka tlase ho othomathike

Haeba u hlile u sa batle ho hlophisa letho ho hang, 'me u na le phepelo e kang ea Ubuntu, u ka leka ho theha sengoloa se nang le litaba tse patiloeng tlas'a spoiler,' me mohlomong ntho e 'ngoe le e' ngoe e tla instola, ntho feela ke, kopi. template ea TeX e kentsoeng tlas'a spoiler ka holimo moo u hlokang teng. Bula Terminal ebe o matha:

user@hostname:~$ cd
user@hostname:~$ touch installmd2pdf.sh

Ebe u e tlatsa ka litaba tse latelang:

Likahare tsa mongolo oa $HOME/installmd2pdf.sh

#!/bin/bash
cd /tmp
sudo apt install texlive-full pandoc -y
wget http://blog.harrix.org/wp-content/uploads/2013/02/PSCyr.zip
unzip -qq PSCyr.zip
cd
mkdir ./PSCyr/fonts/map ./PSCyr/fonts/enc
cp ./PSCyr/dvips/pscyr/*.map ./PSCyr/fonts/map/
cp ./PSCyr/dvips/pscyr/*.enc ./PSCyr/fonts/enc/
echo "fadr6t AdvertisementPSCyr "T2AEncoding ReEncodeFont"" > ./PSCyr/fonts/map/pscyr.map
sudo cp -R ./PSCyr/* $(kpsewhich -expand-var='$TEXMFLOCAL')
sudo texhash
updmap --enable Map=pscyr.map
sudo mktexlsr
sudo touch /usr/share/texlive/template.tex
touch md2pdf
echo "#!/bin/bash" > md2pdf
echo "pandoc --output=$1.pdf --from=markdown_github --latex-engine=pdflatex --listings --template=/usr/share/texlive/template.tex $1" >> md2pdf
sudo cp md2pdf /usr/bin/
sudo chmod 111 /usr/bin/md2pdf

E mathe ka taelo:

user@hostname:~$ sudo bash $HOME/installmd2pdf.sh

O seke wa lebala seo /usr/share/texlive/template.tex e tlameha ho tlatsoa joalo ka ha ho boletsoe karolong "Setšoantšo sa LaTeX bakeng sa phetoho ea md2pdf»kahare.

Ho sebelisa md2pdf

Bula foldara feela ka faele ea Markdown (some_file.md) ho Terminal ebe o tsamaisa taelo:

user@hostname:~$ md2pdf some_file.md

Ka lebaka leo, faele e tla hlaha foldareng some_file.md.pdf.

fihlela qeto e

E itšetlehile ka mokhoa o hlalositsoeng, u ka haha ​​​​setaele leha e le sefe sa lifaele tsa PDF, u ka boela ua fetola liforomo tse ling ho e-na le md, leha e le efe e tšehetsoeng ke Pandoc. Ke iteta sefuba ho tšepa hore ka letsatsi le leng taelo ena e tla ba molemo ho batho ba 3 le halofo.

Source: www.habr.com

Eketsa ka tlhaloso