chiphogg / liec

A fork of Tony Kuphaldt's free textbooks from the Allaboutcircuits.com forums. Main goal is to make it easy to make ebooks.
0 stars 0 forks source link

Switch to markdown or rST #4

Open chiphogg opened 4 years ago

chiphogg commented 4 years ago

Could be pandoc-flavored markdown, with prettier for formatting.

chiphogg commented 4 years ago

To test feasibility of writing in markdown, I tried a round-trip conversion using pandoc 2.9.2, from an output .latex file to .md, and back again to .latex.

Before:


\begin{cbunit} 

\chapter{AC METERING CIRCUITS} 
\minitoc 
\bigskip 

\section{ AC voltmeters and ammeters}
\index{Voltmeter}
\index{Ammeter}
\index{PMMC}
\index{Permanent magnet moving coil}
\index{Meter movement}

AC electromechanical meter movements come in two basic arrangements: those based on DC movement designs, and those engineered specifically for AC use.  Permanent-magnet moving coil (PMMC) meter movements will not work correctly if directly connected to alternating current, because the direction of needle movement will change with each half-cycle of the AC. (Figure~\ref{02224})  Permanent-magnet meter movements, like permanent-magnet motors, are devices whose motion depends on the polarity of the applied voltage (or, you can think of it in terms of the direction of the current).

\begin{figure}[htbp!] 
\centering 
\includegraphics{output/02224} 
\caption{\sl Passing AC through this D'Arsonval meter movement causes useless flutter of the needle. } 
\label{02224} 
\end{figure}

\index{D'Arsonval meter movement}
\index{Diode}
\index{Rectifier}

Markdown:

AC METERING CIRCUITS
====================

 AC voltmeters and ammeters
--------------------------

AC electromechanical meter movements come in two basic arrangements:
those based on DC movement designs, and those engineered specifically
for AC use. Permanent-magnet moving coil (PMMC) meter movements will not
work correctly if directly connected to alternating current, because the
direction of needle movement will change with each half-cycle of the AC.
(Figure [1.1](#02224){reference-type="ref" reference="02224"})
Permanent-magnet meter movements, like permanent-magnet motors, are
devices whose motion depends on the polarity of the applied voltage (or,
you can think of it in terms of the direction of the current).

![*Passing AC through this D'Arsonval meter movement causes useless
flutter of the needle.* ](output/02224){#02224}

After:

\hypertarget{ac-metering-circuits}{%
\section{AC METERING CIRCUITS}\label{ac-metering-circuits}}

\hypertarget{ac-voltmeters-and-ammeters}{%
\subsection{AC voltmeters and
ammeters}\label{ac-voltmeters-and-ammeters}}

AC electromechanical meter movements come in two basic arrangements:
those based on DC movement designs, and those engineered specifically
for AC use. Permanent-magnet moving coil (PMMC) meter movements will not
work correctly if directly connected to alternating current, because the
direction of needle movement will change with each half-cycle of the AC.
(Figure~\protect\hyperlink{02224}{1.1}) Permanent-magnet meter
movements, like permanent-magnet motors, are devices whose motion
depends on the polarity of the applied voltage (or, you can think of it
in terms of the direction of the current).

\includegraphics{output/02224}\{\#02224\}

So: the formatting is a bit nicer in the "after", but there are a lot of deficiencies.

Based on all of this, it looks like markdown won't be a feasible format for writing, since we need to be able to convert all the existing content to our intermediate format automatically using pandoc or something like it.

chiphogg commented 4 years ago

I tried with .rst as well, and the results were similarly discouraging. However, all hope may not be lost for pandoc flavored markdown. It may be possible to do a little custom processing at the end, or find some similar means of converting to a "good" markdown format, if and when we prove that there's a format good enough to give good latex output.

chiphogg commented 4 years ago

I'll need to figure out how to handle the <imagen> (non-floating image) figures. These are equivalent to [h!] instead of [htbp!] in the LaTeX output. What in markdown can give this output?

This answer suggests putting a hard linebreak after, but this changes it from a figure into an inline image. Not what we want. (It removes the caption, among other problems.)

Actually... on closer examination, there are no <imagen> at all, and the only instances of <imagenf> are inside hacky, manual <figure> environments (which seem to exist to do subfigures, and which seem to be rare). So maybe we don't need to worry about this.