繁体   English   中英

使用sed命令将LaTeX文档转换为html?

[英]Converting a LaTeX document to html using sed commands?

我已经被设置为使用sed命令将LaTeX文档转换为html的任务。 我将到目前为止的所有命令都放入了sedscript文件中,可以在LaTeX文件上一次执行所有命令。 LaTeX文档代码当前如下所示(包含到目前为止使用sedscript文件在其上执行的命令):

<HTML> 
 <HEAD>
\TEST TITLE{Capture of colour pictures using visilog}
\author{Neal Snooke}
<BODY>
\makeTEST TITLE

\section{Introduction}

It is possible to use Zeus and the visilog software to capture 
colour images.  Because of the 8 bit deep frame buffer the 
procedure is divided into several stages, explained in the next sections.
The captured pictures can be converted in to almost any format. eg.
PPM, TIFF, GIF etc.

\section{Process overview}

The entire process is divided into the following stages:
\begin{itemize}
\item set up the hardware
\item capture red, green and blue image components
\item combine the RGB files and convert from visilog to a
      more useful single file format
\item adjust the colour balance and quantize the colour palette
\item store in the format of your choice
\end{itemize}

\section{Set up the hardware}

Make sure the following have been performed:
\begin{itemize}
\item login to Zeus do not run Xwindows !
\item Make sure the RGB and sync leads from the colour camera are connected
      to the small grey box (sync generator)
\item Make sure the RGB leads from the sync generator lead to
      channels 1, 2, and 3 (red, green, blue {\em resp}) on the frame
      buffer card on Zeus.  
\item Turn on the camera power supply and sync generator.  The sync generator
      requires a 9V battery to operate.
\item Turn on the secondary colour monitor next to Zeus 
\end{itemize}

\section{Image capture}

To run visilog you must be in the Suntools window system. Visilog must
also be run from the correct directory.
\begin{verbatim}
Zeus: Suntools

Zeus: cd /usr/local/visilog/monitor
Zeus: visilog
\end{verbatim}

If all is well the main visilog window will occupy most of the main
monitor.  Click on the `:256' icon and select an image size of 512.

To test the camera click on the `GRAB' icon select channel 2, quadrant 4,
and and name, a live video picture will appear on the secondary monitor. 
Answer the `freeze frame' question with your choice (does not matter). 
If no image appears check the brightness controls, camera RGB leads,
power supply and sync box battery (green led should be lit). 

The strategy now is to capture 3 images, one from each channel, and
then store them to 3 files called `red.cam', `green.cam', `blue,cam'.
It is a good idea to change directory to your home filestore, or failing
that /tmp will do.  To do this click on the `chd' selection from the
`utilities' menu (default).

A file exists that will force visilog to automatically capture the 
required images and write them to the current directory.  Available
from {\bf ~nns/vlog/capture.j}. Click on the `PLAY' selection and specify
this file.  Visilog will prompt for continuous or step by step play, -
if the first image flickers when using continuous then use step-by-step.
(continuous usually works, but not always ??)

\section{Image Conversion}

Assuming you now have three files (called `red.cam', `green.cam', `blue.cam'
these should be 262144 bytes each) you can run a small program called
{\bf ~nns/vlog/cam2ppm} to merge these into a single file which will be 
in the .PPM
format.  You will need another shell window to perform the conversion.
\begin{verbatim}
MACHINE% cam2ppm > myfile.ppm
\end{verbatim}

Theoretically the image is now ready for use.  However it will usually
have slightly odd colour characteristics, due to the lighting etc.  Also
the 24 bit colour will need to be quantized to 8 bits for most displays.

The best way to achieve this is to use {\bf xv}.  Load the created image
and select `COL EDIT' where the colour components, intensity, contrast
etc can be adjusted via a very nice graphical interface.
The file can subsequently
be written in the format of your choice with the 'SAVE' menu.  The image
can also be cropped if the edges are poor.

The output file will be considerably smaller (PPM, GIF, TIFF) due to the colour 
quantization performed by {\bf xv}.  Beware of postscript as the resulting file
could be MASSIVE 1-2Mb.

As {\bf xv} cannot be run in sunview (!) you must either quit visilog and 
sunview
and run X or log on to another machine to play with the image.
 </BODY>

到目前为止,这是我的论文:

 1i\\ <HTML> \\ <HEAD> s/\\\\begin{document}/<BODY>/ /\\\\end{document}/{ i\\ <\\/BODY> d } $a\\ <P>document automatically converted from LaTeX to HTML /title/{ s/title/TEST TITLE/ } /\\documentstyle/d /\\maketitle/d 

我需要使用sed命令对文档执行以下操作的帮助

-将\\ title {}更改为<HTML> </HTML>

-将\\ section {}更改为<H1> </H1>

-将\\ author {}更改为<B> </B>

-更改\\ begin {itemize} \\ item一些\\ end {itemize}

<UL>
<LI>something
</UL>

-将{\\ bf}更改为<B> </B>

-将{\\ em}更改为<I> </I>

谢谢,如果您可以提供执行上述任务的sed命令:)!

我对你有好处,尝试命令

 latex2html

检查http://www.ctan.org/pkg/latex2html/

\\section{}更改为<H1> </H1>

s#\\section{\([^}]*\)}#<H1>\1</H1>#

\\author{}更改为<B> </B>

s#\\author{\([^}]*\)}#<B>\1</B>#

\\begin{itemize} \\item something \\end{itemize}更改为<UL><LI>something</UL> (假设begin和end在此代码中不在同一行)

/\\begin{itemize}/,/\\end{itemize}/ {
   s/\\begin{itemize}/<UL>/
   s#\\end{itemize}#\
</UL>#
   s/\\item /\
<LI>/g
   }

{\\bf }更改为<B> </B>

s#{\\bf \([^}]*\) }#<B>\1</B>#

-将{\\em }更改为<I> </I>

s#{\\em \([^}]*\) }#<I>\1</I>#

但主要的担心是所有可能的异常,例如\\ bf中的{ ,为此,我们应该添加所有在乳胶中允许的管理。 因此,这是一个起点。 处理异常的一种方法是先以临时格式对其进行翻译(例如: \\{ -> ),然后其翻译回(然后至少要进行两次翻译才能处理异常协议本身[本e样本])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM