% Standard % author Sebastian Meisel Introduction to LaFiC % center LaFiC is in alpha state. Don't use for productive work! % background = red % color = white LaFiC means layout and format in comments, as all layout and format information is put into comment lines. So layout and content are fully separated. For details see Writing Text in LaFiC. % fully: emphasize % layout…comments: italic % Writing…LaFiC: see: Writing Why LaFiC I've been working with LaTeX / XeLaTeX for many years now. Mostly I'm writing prose (no math at all). I often found it disturbing, that I'm forced to create a preamble instead of just start writing. I started using markdown / multimarkdown. Being quite inflexible it didn't convince me either. Also I didn't like the cryptic syntax so much. The LaTeX output was quite cryptic as well. The I remembered my father saying, he'd like to be able to just start writing as with his old typewriter only with a better formating to end with. Last but not least I was thinking a lot about how the layout and formation of a text could be cleaner separated from the content. With LaFiC I can start writing without a thought about the Layout. Still I get a well structured HTML or (Xe)LaTeX document, that I can further render to PDF. % (X…TeX: footnote: The standard templates for LaFiC are all based on XeLaTeX to support UTF-8. Still using LaTeX should be possible. When I'm ready with writing, I can start format by adding human readable comments, beeing my own lector. % heading2 Installation and Usage Prerequisites LaFiC requires Perl > 5.10.1 (tested with Perl 5.26.1). The standard templates require a resent XeLaTeX installation with a least graphicx, hyperref, microtype and xspace. The Gnu Emacs lisp files where tested with Gnu Emacs 25.2.2. lafic2pdf also requires latexmk (tested with version 4.41). % lafic2pdf: mono % latexmk: mono To use LaTeX-Code in HTML output latexmk and pdf2svg (tested with version 0.2.3-1) are required. % latexmk: mono % pdf2svg: mono Installation % label = installation Get source from github using: % github: link: https://github.com/SebastianMeisel/lafics % verbatim git clone https://github.com/SebastianMeisel/lafic.git Add LaFiC directory to $PATH, e.g.: % verbatim export PATH=${PATH}:~/lafic See lafic-mode.el for installation instructions, if you want to use in in Gnu Emacs. % lafic…el: mono % Gnu…Emacs: footnote: GNU Emacs is available as free Software under a GNU General Public License for most modern operating systems (Unix, GNU/Linux, macOS und Windows). Usage For now the LaFiC distribution consists of three scripts that you call with the name of the LaFiC file. % verbatim # lafic2html file.lafic # lafic2tex file.lafic # lafic2pdf file.lafic The last of these is a bash script, first calling lafic2tex and then latexmk. % lafic2tex: mono % latexmk: mono Calling these three script would result in the following files: % verbatim Datei.html Datei.tex Datei.pdf LaFiC major mode in GNU Emacs After installing and activation lafic-mode.el (see Installation), the LaFiC major mode is activated on opening any file with a *.lafic extension. % lafic…el: mono % Installation: see: installation % *…lafic: mono This gives you basic syntax highlighting and some keyboard shortcuts with a C-c prefix. The shortcuts are similar to those used in AUCTeX. % C-c: mono % heading2 Writing text in LaFiC % label = Writing Lines and paragraphs The content is presented in two forms, which also include the most basic layout: There are lines and paragraphs. % lines: emphasize % paragraphs: emphasize The difference is not so much the length, but lines include none of the punctation marks (., ?, !, :). If no further layout information is provided, these are interpreted as headings. % (…): emphasize The first line is interpreted as the title and presented as <h1>, when converted to Html, and \title, when converted to LaTeX. % first (line is interpreted): emphasize % Html: smallcaps Further lines will be converted to <h3> (Html) or \section (LaTeX), if no otherwise specified. % lines: emphasize % Html: smallcaps This way simple documents may be structured with no explicit layout information at all. Comments You can add comments to your text, by starting a paragraph with two % chars with no leading spaces: % no…spaces: bold % verbatim %% This is a comment. % verbatim %% This is a longer comment, that spreads over several %% lines. It is important that it is not connected to a line %% of the general content. Formated paragraphs Paragraphs can be formated by adding a line before the paragraph, that starts with a % char, followed by a single word. There are some predefined keywords, like quote or quotation for – well a quotation. If the keyword is unknown, it will be converted to an environment name in LaTeX or the name of a <div> in Html. % verbatim % quote This is a quotation. % quote This is a quotation. Two paragraph starting with the same keyword will be concatenated to one block / environment. % Verbatim % center This paragraph is centered % Verbatim % center This one, too. Becomes: % center This paragraph is centered % center This one, too. The following keywords are available at the moment: * quote for quote environment / <blockquote> * quotation for quotation environment / <blockquote> * center for center environment / <div class="center">, with text-align=center Formated lines % label = form_lines Line are formated in the same way, only they are converted to macros (LaTeX) oder <span> names (HTML). Know keywords are: * "title", "h1" or "heading1" for \title / <h1> * "part", "h2", "heading" or "chapter" for \part, \chapter / <h2> * "section", "h3" or "heading3" for \section / <h3> * "subsection", "h4" or "heading4" for \subsection / <h4> * "subsubsection", "h5" or "heading5" for \subsubsection / <h5> * "paragraph", "h6" or "heading6" for \paragraph / <h6> * "h" or "heading" for \addsec * "marginpar" or "annote" for \marginpar / <span class="annote"> % "chapter": footnote: Chapter is not available in standard template as it is not available in the document class used. % "…": mono % verbatim % heading5 This is a subsubsection % heading5 This is a subsubsection % heading4 Metadata Metadata like author and date can be provided as formated lines: % verbatim % author Frank Sample % verbatim % date nevermas At the moment these tow are also the only metadata keywords provided. Inline formation If you want to format words or sequences in a paragraph (or line if needed), you add format lines with a leading % after a paragraph. It has two parts: % enumerate * the word or the sequence to be formated in the form start…end. - a keyword. The both are separated by a colon. % verbatim Hallo dear old world! % Hallo: bold % ol…ld: emphasize Becomes: Hallo dear old world! % Hallo: bold % ol…ld: emphasize Known format keywords are: * "bold" for \textbf / <b> * "emphasize" for \emph / <em> * "italic" for \textit / <i> * "mono" or "typewriter" for \texttt / <span class="tt"> * "smallcaps" for \textsc / <span class="sc"> * "superscript" for \textsuperscript / <sup> * "subscript" for \textsubscript / <sub> % "…": mono If the keyword is unknown, it is converted to a macro (LaTeX) oder <span> (HTML) name. Some keywords need a second argument which is added after a second colon: % verbatim This is a green world! % green: color: red becomes: This is a green world! % green: color: red Know keywords of that kind are: * "url" or "link" for \href / <a href='[url]'> * "see" for \nameref / <a href='#[label]'> * "footnote" for \footnote / <a class='fn' href='xfn[x]'> * "color" for \textcolor / <span style='color: [color]'> % "footnote": footnote : In HTML documents footnote are presented in an <ol> list that is placed in a <div id="footnotes"> container at the end of the document. Each footnote is placed in a <li id="fnx"> element. Parameters It is also possible to add some additional parameters to the whole paragraph or line. This is done quite similar to the inline formats, but with a equal sign separating the keyword from the value: % verbatim This text is white on blue and aligned to the right. % background = blue % color = white % align = right becomes: This paragraph has a red on blue text and is aligned to the right. % background = blue % color = red % align = right Known parameters are: * "name" or "label" for \label / <?? id="[id]"> that is referred to by the "see" keyword. * "background" for \colorbox / <div style='background: [color]'>. * "color" for \textcolor / <div style='color: [color]'>. * "align" for \raggedleft, \centering or \raggedright / <div style='text-align: [align]'>. Lists Lists are the only things, that need some kind of markup: You have to start each topic of the list with one of the following chars: –, *, +, -. It doesn't matter, which one you choose. You may indent the lines, but that has no influence on the layout. % –…- : mono % verbatim * Top 1. - Top 2. * Top 1. - Top 2. For multilevel lists you have to choises to raise or decrease the level: The clean LaFiC style would be, to start a new paragraph and add the keyword »% level+« or »% level-« at the end. % »…«: mono % verbatim * Top 1. * Top 2. % verbatim * Top 2a. * Top 2b. % level+ * Top 1. * Top 2. * Top 2a. * Top 2b. % level+ Or you can write the list in one paragraph, marking the raise or decrease of the level with a > or < at the beginning of a single line. % >: mono % <: mono % verbatim * Top 1. * Top 2. > * Top 2a. * Top 2b. < * Top 3 * Top 1. * Top 2. > * Top 2a. - Top 2b. < * Top 3 Images The simplest way to put an image into a LaFiC file is a line with the image name, with a know extention: png, jpg, jpeg, gif. % verbatim Image.png % height = 40% % align = center Image.png % height = 40% % align = center The following parameters are available for formating: * height * width or length Note that this will not put an figure environment in LaTeX files, so the image won't float this way. For this to achieve to have to put % image, %img or %figure before the line. % verbatim %image Image.png % width = 40% % caption = "Moon and Mars" %image Image.png % width = 40% % caption = "Moon and Mars" This also gives you two more parameters to use: * name or label * caption Colors The following colors are accepted as argument to parameters for color or background: * gray * green * yellow * blue * red * white % green: color: green % yellow: color: yellow % blue: color: blue % red: color: red % white: color: white % background = gray Line breaks Line breaks within paragraphs are normally removed, if the paragraph is not marked to be verbatim. To keep the line breaks, just add % breaks lines or % br after the paragraph. % %…lines (or): mono % (or) %…br: mono % verbatim Shall I compare thee to a summer’s day? Thou art more lovely and more temperate: Rough winds do shake the darling buds of May, And summer’s lease hath all too short a date: % break lines Sometime too hot the eye of heaven shines, And often is his gold complexion dimmed; And every fair from fair sometime declines, By chance, or nature’s changing course, untrimmed: % break lines % (William Shakespeare) % William…Shakespeare: emphasize % align = right LaTeX-Code It is possible to add a paragraph with pure LaTeX-Code like this: % verbatim % LaTeX $\left(\frac{1}{\sqrt{x}}\right)$ % align = center % LaTeX $\left(\frac{1}{\sqrt{x}}\right)$ % align =center This is done by pasting the paragraph into the templates/standalone.tmp.tex files. You can create a custom standalone.tmp.tex file in your working directory. The (Xe)LaTeX file is compiled to a PDF file and then to a SVG file by pdf2svg. The SVG is than pasted to the html output file. % templates/: mono % stand…tex: mono % heading2 Customization It is possible to customize LaFiC in various ways. Templates LaFiC uses templates for LaTeX and HTML output. These templates are locates in the /templates subdirectory of the /lafic directory. The suffix of these files is .tmp.tex for LaTeX and .tmp.html for HTML output. % /templates: mono % /lafic: mono % .tmp.tex: mono % .tmp.html: mono You can create your own templates an place them there. LaFiC requires for LaTeX templates at least the graphicx package for images, hyperref for links and xcolor with x11names, dvipsnames* and svgnames option for color support: % graphicx: mono % hyperref: mono % xcolor: mono % x11…psnames: mono % svgnames: mono % Verbatim \usepackage{graphicx} \usepackage[x11names, dvipsnames*, svgnames]{xcolor} \usepackage[hyperindex=false, pdfpagelabels, pageanchor, hyperfootnotes=false, bookmarksopen, pdfpagemode=UseOutlines]{hyperref} The templates are called by putting it's name without suffix in the very first line of a document with a leading % char: % verbatim % template It is also possible to create a template for a specific document. Such templates must be placed in the same directory as the document and have the same basename: % Verbatim $ ls -1 . .. example.lafic example.tmp.tex example.tmp.html The templates must contain placeholders for metadata like title and author and for the content of the document. For LaTeX that would be %TITLE% and %TEXT%: % Verbatim \documentclass{article} … %TITLE% \begin{document} %TEXT% \end{document} For Html it's <!-- TITLE --> and <!-- TEXT -->: In Html-Vorlagen heißen die Platzhalter <!-- TITLE --> und <!-- TEXT -->: % Verbatim <html> <head> <!-- TITLE --> </head> <body> <!-- TEXT --> </body> </html> % heading3 Advanced: Custom keywords By creating custom LaTeX environment and macros as well as the corresponding css classes, you can use your own keywords. Look in the /examples subdirectory for inspiration. % /examples: mono Stylesheets In the /styles subdirectory there is a standard.css file, which contains the CSS stylesheet used by the standard HTML templates for LaFiC. You can place your own stylesheets here to refer to them from custom templates. For now you have to manually copy or link the /styles directory to your working directory. % /styles: mono % standard…css: mono % heading3 lafic.config.pl % lafic…pl: mono In this file in the LaFiC directory you set some preferences. At the moment this are just two: * lang where you have the option to set another language then English as your preferred language. At the moment the only option here is de_DE for German, as this is my first language. * author is for now the only way to specify the author's name for your LaFiC documents. I hope to provide an in-document option soon. % lang: mono % de…DE: mono % author: mono The content of this document is actually a perl construct an must be written in the form: % verbatim key => "value", Please observe the comma at the end of each line.