mirror of https://github.com/CGAL/cgal
* new feature: regular expressions (based on posix regex)
* bugfix: based on regex, \labels inside sections/chapters etc
are now correctly handled (ie, html-anchors above <h1> etc)
* improved layout for pkgdesc
This commit is contained in:
parent
64a4aba329
commit
3e9da694df
|
|
@ -1056,6 +1056,8 @@ Manual_tools/src/latex_converter_config/gif/cc_wp.gif -text svneol=unset#unset
|
|||
Manual_tools/src/latex_converter_config/gif/cc_wr.gif -text svneol=unset#unset
|
||||
Manual_tools/src/latex_converter_config/gif/cc_zeta.gif -text svneol=unset#unset
|
||||
Manual_tools/src/mstring.doc -text
|
||||
Manual_tools/src/regex++.C -text
|
||||
Manual_tools/src/regex_dictionary.C -text
|
||||
Manual_tools/sty/eps_tabs/cc_Class.eps -text
|
||||
Manual_tools/sty/eps_tabs/cc_Class.pdf -text svneol=unset#unset
|
||||
Manual_tools/sty/eps_tabs/cc_Concept.eps -text
|
||||
|
|
|
|||
|
|
@ -136,7 +136,9 @@ OBJHTML = lexer.o \
|
|||
cpp_formatting.o \
|
||||
input.o \
|
||||
output.o \
|
||||
cc_extract_html.o
|
||||
cc_extract_html.o \
|
||||
regex++.o \
|
||||
regex_dictionary.o
|
||||
|
||||
OBJIMAGES = cc_extract_images_lexer.C cc_extract_images.o
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include <regex_dictionary.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
typedef std::map< string, string, Case_insensitive_string_greater_than > String_map;
|
||||
|
|
@ -1082,9 +1084,9 @@ string // macro
|
|||
handle_chapter( const string&, string param[], size_t n, size_t opt) {
|
||||
NParamCheck( 1, 0);
|
||||
push_current_output();
|
||||
string chapter_title( param[0]);
|
||||
crop_string( chapter_title);
|
||||
remove_separator( chapter_title);
|
||||
//string chapter_title( param[0]);
|
||||
//crop_string( chapter_title);
|
||||
//remove_separator( chapter_title);
|
||||
|
||||
string new_main_filename;
|
||||
string new_main_filepath = macroX( "\\lciInputPath");
|
||||
|
|
@ -1345,6 +1347,32 @@ sorted_map_is_empty( const string&, string param[], size_t n, size_t opt) {
|
|||
}
|
||||
|
||||
|
||||
/* regular expressions */
|
||||
|
||||
|
||||
string
|
||||
handle_regex_register( const string&, string param[], size_t n, size_t opt) {
|
||||
NParamCheck( 2, 0);
|
||||
regex_register( param[0], param[1] );
|
||||
return string();
|
||||
}
|
||||
|
||||
string
|
||||
handle_regex_does_match( const string&, string param[], size_t n, size_t opt) {
|
||||
NParamCheck( 2, 0);
|
||||
if( regex_does_match( param[0], param[1] ) )
|
||||
return string("\\lcTrue");
|
||||
else
|
||||
return string("\\lcFalse");
|
||||
}
|
||||
|
||||
string
|
||||
handle_regex_result( const string&, string param[], size_t n, size_t opt) {
|
||||
NParamCheck( 1, 0);
|
||||
unsigned int index = atoi( param[0].c_str() );
|
||||
return regex_get_submatch(index);
|
||||
}
|
||||
|
||||
// Initialize
|
||||
// ======================================================================
|
||||
void init_internal_macros() {
|
||||
|
|
@ -1422,7 +1450,7 @@ void init_internal_macros() {
|
|||
insertInternalGlobalMacro( "\\lciIfFileExists", if_file_exists, 1);
|
||||
insertInternalGlobalMacro( "\\lciCopyFile", copy_file, 2);
|
||||
|
||||
insertInternalGlobalMacro( "\\lciChapter", handle_chapter, 1);
|
||||
insertInternalGlobalMacro( "\\lciChapter", handle_chapter, 0);
|
||||
|
||||
insertInternalGlobalMacro( "\\lciPopOutput", pop_output, 0);
|
||||
insertInternalGlobalMacro( "\\lciPushOutput", push_output, 1);
|
||||
|
|
@ -1435,6 +1463,10 @@ void init_internal_macros() {
|
|||
insertInternalGlobalMacro( "\\lciIncludeOnly", handle_include_only, 1);
|
||||
insertInternalGlobalMacro( "\\lciIfToBeIncluded", handle_to_be_included, 1);
|
||||
insertInternalGlobalMacro( "\\lciToHtmlWidth", to_html_width, 1);
|
||||
|
||||
insertInternalGlobalMacro( "\\lciRegexRegister", handle_regex_register, 2 );
|
||||
insertInternalGlobalMacro( "\\lcRegexDoesMatch", handle_regex_does_match, 2 );
|
||||
insertInternalGlobalMacro( "\\lcRegexResult", handle_regex_result, 1 );
|
||||
}
|
||||
|
||||
// EOF //
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
\newcommand{\ccAuto}{\lcAuto}
|
||||
|
||||
|
||||
|
||||
% ###########################################################################
|
||||
% |
|
||||
% | o
|
||||
|
|
@ -987,6 +986,12 @@
|
|||
\newcommand{\lciFlushPkgDescription}[2]{%
|
||||
\lciFlushPkgDescriptionX{#X1}{#X2}{\ccValueofPkgName}%
|
||||
}
|
||||
|
||||
\newcommand{\lciCheckForLabelInsideHeadingX}[2]{%
|
||||
\lciCheckForLabelInsideHeading{#XC1}{#2}{\lciLocalVariableLabel}%
|
||||
\lciLocalVariableLabel%
|
||||
}
|
||||
|
||||
\newcommand{\lciFlushPkgDescriptionX}[3]{%
|
||||
\lciIfEmpty{#X3}{}{%
|
||||
\lciIfEmpty{\lciCurrentPartName}{}{%
|
||||
|
|
@ -994,24 +999,20 @@
|
|||
\gdef\lciCurrentPartName{}%
|
||||
}%
|
||||
\lciPushOutput{description}%
|
||||
\lcRawHtml{<h3>}\ccValueofPkgName\lcRawHtml{</h3>}
|
||||
\lcRawHtml{<table><tr valign="top"><td }%
|
||||
%\lciPkgDescriptionIsOddEntry
|
||||
% {\lcRawHtml{ bgcolor="#C0C0C0" }}
|
||||
% {}
|
||||
\lcRawHtml{width="58\%">}
|
||||
\lcRawHtml{<tr><td colspan="3">}%
|
||||
\lciCheckForLabelInsideHeadingX{\ccValueofPkgName}{\lciCurrentPackageName}%
|
||||
\lcRawHtml{<h3>}\lciCurrentPackageName\lcRawHtml{</h3></td></tr>}
|
||||
%\lcRawHtml{<TABLE>}
|
||||
\lcRawHtml{<tr valign="top"><td width="75\%">}
|
||||
\ccValueofPkgSummary
|
||||
%\lcRawHtml{</td><td width="4\%">}
|
||||
\lcRawHtml{</td><td }%
|
||||
%\lciPkgDescriptionIsOddEntry
|
||||
% {}
|
||||
% {\lcRawHtml{ bgcolor="#C0C0C0" }}
|
||||
\lcRawHtml{width="38\%">}
|
||||
\lcRawHtml{</td><td width="2\%">}
|
||||
\lcRawHtml{</td><td width="23\%">}
|
||||
\ccValueofPkgMaturity
|
||||
\ccValueofPkgDependsOn
|
||||
\ccValueofPkgLicense
|
||||
\lcRawHtml{<a href="#C1">User Manual</a> <a href="#C2">Reference Manual</a>}
|
||||
\lcRawHtml{</td></td></table>}
|
||||
\lcRawHtml{</td></td>}
|
||||
%\lcRawHtml{</table>}
|
||||
\lciPopOutput%
|
||||
\gdef\ccValueofPkgName{}%
|
||||
%\lciPkgDescriptionIsOddEntry
|
||||
|
|
@ -1052,6 +1053,7 @@
|
|||
\lciSortedMapClear{TocReferenceLinks}
|
||||
}
|
||||
}
|
||||
|
||||
% ___________________________________________________________________________
|
||||
% ###########################################################################
|
||||
% | EOF
|
||||
|
|
|
|||
|
|
@ -70,8 +70,7 @@ l% ___________________________________________________________________________
|
|||
% |#########################################################################|
|
||||
|
||||
|
||||
% Load latex_to_html.sty that provides the basic converter capabilities.
|
||||
% redefined in latex_to_html.sty
|
||||
|
||||
\newcommand{\lcFalse}[2]{#2}
|
||||
\newcommand{\lcTrue}[2]{#1}
|
||||
|
||||
|
|
@ -95,6 +94,37 @@ l% ___________________________________________________________________________
|
|||
\newcommand{\lcStyleFile}[1]{\lciInputStyleFile{\lciConfigPath}{#XC1}}
|
||||
\newcommand{\lciInputStyleFile}[2]{\lciInclude{#XC1#C2.sty}}
|
||||
}
|
||||
|
||||
% ___________________________________________________________________________
|
||||
% ###########################################################################
|
||||
% | Regular Expressions
|
||||
% ###########################################################################
|
||||
|
||||
|
||||
\newcommand{\lcRegexRegister}[1]{%
|
||||
\def\lciRegexNameToBeRegistered{#1}%
|
||||
\lciParseUntilDelimiter{\lciRegexRegisterX}}
|
||||
|
||||
\newcommand{\lciRegexRegisterX}[1]{\lciRegexRegisterXX{\lciRegexNameToBeRegistered}{#1}}
|
||||
\newcommand{\lciRegexRegisterXX}[2]{\lciRegexRegister{#XC1}{#C2}}
|
||||
|
||||
\lcRegexRegister{checkforlabel}@(.+)(\\label[^\}]+\})(.*)@
|
||||
|
||||
|
||||
\newcommand{\lciCheckForLabelInsideHeading}[3]{%
|
||||
\lcRegexDoesMatch{checkforlabel}{#1}{%
|
||||
% xdef doesnt work, either ..
|
||||
\gdef#2{\lcRegexResult{1}\lcRegexResult{3}}%
|
||||
\gdef#3{\lcRegexResult{2}}
|
||||
}{%
|
||||
\gdef#2{#1}%
|
||||
\gdef#3{}%
|
||||
}%
|
||||
}%
|
||||
|
||||
|
||||
% Load latex_to_html.sty that provides the basic converter capabilities.
|
||||
% redefined in latex_to_html.sty
|
||||
\lcStyleFile{latex_to_html}
|
||||
|
||||
% print own release number
|
||||
|
|
@ -196,6 +226,7 @@ l% ___________________________________________________________________________
|
|||
\lciHtmlFileHeader{Package Description}%
|
||||
\lciHtmlNavigationTop
|
||||
\lcRawHtml{<H1>Package Description</H1>}
|
||||
\lcRawHtml{<table>}
|
||||
\lciPopOutput%
|
||||
}{%
|
||||
% print remaining footnotes at the end of the conversion
|
||||
|
|
@ -211,6 +242,7 @@ l% ___________________________________________________________________________
|
|||
\lciOpenTmpFile{\lciIndexHeader}\lciIndexFileHeader\lciCloseFile
|
||||
\lciOpenTmpFile{\lciIndexFooter}\lciIndexFileFooter\lciCloseFile
|
||||
\lciPushOutput{description}%
|
||||
\lcRawHtml{</table>}
|
||||
\lciHtmlNavigationBottom
|
||||
\lciHtmlFileFooter%
|
||||
\lciPopOutput%
|
||||
|
|
@ -1087,14 +1119,18 @@ l% ___________________________________________________________________________
|
|||
\gdef{\lciIfHtmlLinks}{\lcTrue}%
|
||||
\gdef{\lciIfHtmlIndex}{\lcTrue}%
|
||||
\refstepcounter{chapter}%
|
||||
\lciChapter{#1}% does also a PushOutput
|
||||
|
||||
\lciCheckForLabelInsideHeading{#1}%
|
||||
{\lciLocalVariableChapterNameTOC}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciChapter% does also a PushOutput
|
||||
% cross linking rules
|
||||
\lciPushOutput{anchor}%
|
||||
\lcRawHtml{i Next_chapter_link_}\value{part}\_\value{chapter}%
|
||||
\lcRawHtml{ <div class="NavNext"><hr> Next chapter: <a href="}%
|
||||
\lcRawHtmlExpanded{\lciReplaceWithCurrentPathToken}%
|
||||
\lcRawHtmlExpanded{\lciOutputBasename}%
|
||||
\lcRawHtml{">}#1\lcRawHtml{</a>
|
||||
\lcRawHtml{">}\lciLocalVariableChapterNameTOC\lcRawHtml{</a>
|
||||
}%
|
||||
\lcRawHtml{i Up_chapter_link_}\value{part}\_\value{chapter}%
|
||||
\lcRawHtml{ <a href="}%
|
||||
|
|
@ -1111,14 +1147,14 @@ l% ___________________________________________________________________________
|
|||
% however, setting this to a default of TRUE at the beginning of each
|
||||
% chapter seems safe.
|
||||
% file header
|
||||
\lciHtmlFileHeader{#1}%
|
||||
\lciHtmlFileHeader{\lciLocalVariableChapterNameTOC}%
|
||||
\lciHtmlNavigationTop
|
||||
\lciIfLessExpanded{\lciCountersecnumdepth}{0}%
|
||||
{%
|
||||
\lciHtmlChapterToc{\thechapter}{#1}%
|
||||
\lciHtmlChapterToc{\thechapter}{\lciLocalVariableChapterNameTOC}%
|
||||
\lciHtmlChapterHeader{#2}%
|
||||
}{%
|
||||
\lciHtmlChapterToc{\thechapter}{\thechapter~~~#1}%
|
||||
\lciHtmlChapterToc{\thechapter}{\thechapter~~~\lciLocalVariableChapterNameTOC}%
|
||||
\lciHtmlChapterHeader{Chapter \thechapter\\#2}%
|
||||
}%
|
||||
}
|
||||
|
|
@ -1150,6 +1186,7 @@ l% ___________________________________________________________________________
|
|||
\newcommand{\section@om}{%
|
||||
\lciEndSection
|
||||
\refstepcounter{section}%
|
||||
\lciLocalVariableLabel
|
||||
\lciIfLessExpanded{\lciCountersecnumdepth}{1}{%
|
||||
\lciHtmlSectionToc{\thesection}{#1}%
|
||||
\lciHtmlSectionHeader{#2}}%
|
||||
|
|
|
|||
|
|
@ -432,19 +432,26 @@
|
|||
\newcommand{\lciHtmlPartPkgDesciption}[1]{
|
||||
\lciPushOutput{description}
|
||||
\lcRawHtml{
|
||||
<table width="100\%" border="0" cellspacing="0" cellpadding="0"><tr><td>
|
||||
<tr><td colspan="3">
|
||||
<h2 class="PkgDescPart"><br>}#XC1\lcRawHtml{</h1>
|
||||
</td></tr></table>}
|
||||
</td></tr>}
|
||||
\lciPopOutput
|
||||
}
|
||||
|
||||
% Args: <header-text>
|
||||
\newcommand{\lciHtmlChapterHeader}[1]{\lcRawHtml{
|
||||
<h1>}#C1\lcRawHtml{</h1>
|
||||
\newcommand{\lciHtmlChapterHeader}[1]{
|
||||
\lciCheckForLabelInsideHeading{#C1}%
|
||||
{\lciLocalVariableChapterName}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciLocalVariableLabel
|
||||
\lcRawHtml{<h1>}\lciLocalVariableChapterName\lcRawHtml{</h1>
|
||||
}}
|
||||
|
||||
% Args: <anchor-counter> <toc-entry>: Respect secnumdepth counter.
|
||||
\newcommand{\lciHtmlChapterToc}[2]{%
|
||||
%\lciCheckForLabelInsideHeading{#2}%
|
||||
% {\lciLocalVariableChapterName}%
|
||||
% {\lciLocalVariableLabel}%
|
||||
\lciIfEmpty{#C1}{}{\lciIfLessExpanded{\lciCountertocdepth}{0}{}{%
|
||||
\lcRawHtml{<a name="Chapter_}#C1\lcRawHtml{"></a>}}}
|
||||
\lciIfLessExpanded{\lciCountertocdepth}{0}{}{%
|
||||
|
|
@ -454,7 +461,7 @@
|
|||
% \lcRawHtml{##Chapter_}#C1 % omit anchor, we start at the page top
|
||||
\lcRawHtml{ <tr><td class="TocChapter" colspan="6">
|
||||
<!-- --------------------------------------------------- -->
|
||||
<a class="TocLinkChapter" href="}\lcRawHtmlExpanded{\lciOut}%
|
||||
<a class="TocLinkChapter" href="}\lcRawHtmlExpanded{\lciOut}% \lciLocalVariableChapterName
|
||||
\lcRawHtml{"
|
||||
>}#C2\lcRawHtml{</a>
|
||||
</td></tr>
|
||||
|
|
@ -464,12 +471,20 @@
|
|||
|
||||
|
||||
% Args: <header-text>:
|
||||
\newcommand{\lciHtmlSectionHeader}[1]{\lcRawHtml{
|
||||
<h2>}#C1\lcRawHtml{</h2>
|
||||
}}
|
||||
\newcommand{\lciHtmlSectionHeader}[1]{%
|
||||
\lciCheckForLabelInsideHeading{#C1}%
|
||||
{\lciLocalVariableSectionName}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciLocalVariableLabel
|
||||
\lcRawHtml{<h2>}\lciLocalVariableSectionName\lcRawHtml{</h2>
|
||||
}
|
||||
}
|
||||
|
||||
% Args: <anchor-counter> <toc-entry>: Respect secnumdepth counter.
|
||||
\newcommand{\lciHtmlSectionToc}[2]{%
|
||||
\lciCheckForLabelInsideHeading{#C2}%
|
||||
{\lciLocalVariableSectionName}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciIfLessExpanded{\lciCountertocdepth}{1}{}{%
|
||||
\lcRawHtml{<a name="Section_}#C1\lcRawHtml{"></a>}
|
||||
\edef\lciOut{\lciOutputFilename}%
|
||||
|
|
@ -480,16 +495,16 @@
|
|||
\lcRawHtml{ <td class="TocSection" colspan="5">
|
||||
<a class="TocLinkSection" href="}\lcRawHtmlExpanded{\lciOut}%
|
||||
\lcRawHtml{##Section_}#C1\lcRawHtml{"
|
||||
>}#C2\lcRawHtml{</a>
|
||||
>}\lciLocalVariableSectionName\lcRawHtml{</a>
|
||||
</td>
|
||||
</tr>
|
||||
}%
|
||||
\lciPopOutput}}
|
||||
|
||||
% Args: <header-text>:
|
||||
\newcommand{\lciHtmlReferenceHeader}[1]{\lcRawHtml{
|
||||
<h2>}#C1\lcRawHtml{</h2>
|
||||
}}
|
||||
\newcommand{\lciHtmlReferenceHeader}[1]{
|
||||
\lcRawHtml{<h2>}#C1\lcRawHtml{</h2>}
|
||||
}
|
||||
|
||||
% Args: <anchor-counter> <toc-entry>: Respect secnumdepth counter.
|
||||
\newcommand{\lciHtmlReferenceToc}[2]{%
|
||||
|
|
@ -514,13 +529,20 @@
|
|||
% Args: <anchor-counter> <header-text>: if anchor counter is empty, no
|
||||
% anchor is defined. Respect secnumdepth counter.
|
||||
\newcommand{\lciHtmlSubsectionHeader}[2]{%
|
||||
\lciCheckForLabelInsideHeading{#C2}%
|
||||
{\lciLocalVariableSubSectionName}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciLocalVariableLabel
|
||||
\lciIfEmpty{#C1}{}{\lciIfLessExpanded{\lciCountertocdepth}{2}{}{%
|
||||
\lcRawHtml{<a name="Subsection_}#C1\lcRawHtml{"></a>}}}\lcRawHtml{
|
||||
<h3>}#C2\lcRawHtml{</h3>
|
||||
<h3>}\lciLocalVariableSubSectionName\lcRawHtml{</h3>
|
||||
}}
|
||||
|
||||
% Args: <anchor-counter> <toc-entry>
|
||||
\newcommand{\lciHtmlSubsectionToc}[2]{%
|
||||
\lciCheckForLabelInsideHeading{#C2}%
|
||||
{\lciLocalVariableSubSectionName}%
|
||||
{\lciLocalVariableLabel}%
|
||||
\lciIfLessExpanded{\lciCountertocdepth}{2}{}{%
|
||||
\edef\lciOut{\lciOutputFilename}%
|
||||
\lciPushOutput{toc}%
|
||||
|
|
@ -529,8 +551,7 @@
|
|||
}\lciTocIndentWidth\lciTocIndentWidth
|
||||
\lcRawHtml{ <td class="TocSubsection" colspan="4">
|
||||
<a class="TocLinkSubsection" href="}\lcRawHtmlExpanded{\lciOut}%
|
||||
\lcRawHtml{##Subsection_}#C1\lcRawHtml{"
|
||||
>}#C2\lcRawHtml{</a>
|
||||
\lcRawHtml{##Subsection_}#C1\lcRawHtml{">}\lciLocalVariableSubSectionName\lcRawHtml{</a>
|
||||
</td>
|
||||
</tr>
|
||||
}%
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
#!/bin/bash
|
||||
# **************************************************************************
|
||||
#
|
||||
#
|
||||
# latex_to_html
|
||||
# ===================
|
||||
# LaTeX to HTML converter. General purpose converter (with some
|
||||
# limitations), but particularly specialized in converting manuals
|
||||
# with C++ specifications written with the cc_manual.sty.
|
||||
#
|
||||
# Conversion works in two steps: First all TeX files are converted into
|
||||
# HTML. Meanwhile the necessary information for the cross links is
|
||||
# Conversion works in two steps: First all TeX files are converted into
|
||||
# HTML. Meanwhile the necessary information for the cross links is
|
||||
# collected as set of rules. In the second step the hyperlinks
|
||||
# are generated for all HTML files.
|
||||
#
|
||||
#
|
||||
# Besides programs and scripts distributed with this LaTeX converter,
|
||||
# the following programs are necessary to run the converter
|
||||
#
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
# Peter Hachenberger and Lutz Kettner
|
||||
# Revision : $Id$
|
||||
# Date : $Date$
|
||||
#
|
||||
#
|
||||
# **************************************************************************
|
||||
|
||||
# allow wildcard file expansions to become empty if nothing matches
|
||||
|
|
@ -58,7 +58,7 @@ fi
|
|||
|
||||
# The header files within the \ccInclude macro can be linked to the original
|
||||
# header files if the -header option is given to the cc_extract_html program.
|
||||
# The environment variable LATEX_CONV_HEADER is used as default.
|
||||
# The environment variable LATEX_CONV_HEADER is used as default.
|
||||
# If it is not set, the default setting is empty and include files are not
|
||||
# linked.
|
||||
# LATEX_CONV_HEADER=""
|
||||
|
|
@ -177,7 +177,7 @@ lgout() {
|
|||
else
|
||||
Buf="$@"
|
||||
declare -i len2=$CurrentLen+${#Buf}
|
||||
if [ $len2 -gt 78 ]; then
|
||||
if [ $len2 -gt 78 ]; then
|
||||
echo ""
|
||||
echo "" >> $LogFile
|
||||
fi
|
||||
|
|
@ -214,7 +214,7 @@ error() {
|
|||
if [ $CurrentLen -gt 0 ]; then echo ""; fi
|
||||
echo "${ErrorColor}ERROR: $@${ResetColor}" 1>&2
|
||||
fi
|
||||
if [ $CurrentLen -gt 0 ]; then
|
||||
if [ $CurrentLen -gt 0 ]; then
|
||||
echo "" >> $LogFile
|
||||
fi
|
||||
echo "ERROR: $@" >> $LogFile
|
||||
|
|
@ -237,7 +237,7 @@ error_usage() {
|
|||
echo "${ErrorColor}ERROR: $@${ResetColor}" 1>&2
|
||||
usage 1>&2
|
||||
fi
|
||||
if [ $CurrentLen -gt 0 ]; then
|
||||
if [ $CurrentLen -gt 0 ]; then
|
||||
echo "" >> $LogFile
|
||||
fi
|
||||
echo "ERROR: $@" >> $LogFile
|
||||
|
|
@ -301,9 +301,9 @@ print_time() {
|
|||
run_command() {
|
||||
ExitCode=0
|
||||
cmd=${@//(/\\(};
|
||||
cmd=${cmd//)/\\)};
|
||||
cmd=${cmd//)/\\)};
|
||||
if [ $Quiet -eq 0 ] ; then
|
||||
{
|
||||
{
|
||||
if ! eval "$cmd" 2>&1 ; then
|
||||
# We need to set ExitCode=1, but that won't work with that pipe.
|
||||
# Instead we touch a file and test that later.
|
||||
|
|
@ -324,7 +324,7 @@ run_command() {
|
|||
if [ -r $LogFile.tmp ]; then
|
||||
# copy temp logfile to final logfile and remove escape sequences (color)
|
||||
cat $LogFile.tmp | sed 's/[[][0-9]*m//g' >> $LogFile
|
||||
if grep -i '^error' $LogFile.tmp > /dev/null ; then
|
||||
if grep -i '^error' $LogFile.tmp > /dev/null ; then
|
||||
ErrorInLogfile=1
|
||||
fi
|
||||
rm $LogFile.tmp
|
||||
|
|
@ -342,9 +342,9 @@ anchor_filter() {
|
|||
cat cc_anchor_rules.stage_1 \
|
||||
cc_anchor_rules.stage_2 \
|
||||
cc_anchor_rules.stage_3 \
|
||||
| sed 's/REPLACE_WITH_CURRENT_PATH//g' > cc_anchor_rules
|
||||
| sed 's/REPLACE_WITH_CURRENT_PATH//g' > cc_anchor_rules
|
||||
|
||||
cc_anchor_filter cc_anchor_rules $1
|
||||
cc_anchor_filter cc_anchor_rules $1
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
|
|
@ -367,8 +367,8 @@ convert() {
|
|||
|
||||
# relative path, can be empty. If not empty, it has a trailing '/'.
|
||||
PathName=${1%$BaseName}
|
||||
if [ "$PathName" != "" ]; then
|
||||
if [[ $PathName == /* ]]; then
|
||||
if [ "$PathName" != "" ]; then
|
||||
if [[ $PathName == /* ]]; then
|
||||
error 3 "LaTeX filename must be given with a relative path."
|
||||
fi
|
||||
${MakePath} ${TmpDir}/${PathName}
|
||||
|
|
@ -408,7 +408,7 @@ convert() {
|
|||
for dir in ${AllSubDirs} ; do
|
||||
cd $dir
|
||||
cat cc_anchor_rules.stage_1 | sed 's/\[cccbegin\]//g' | sed 's/\[cccend\]//g' > cc_anchor_rules.stage_1.tmp
|
||||
mv cc_anchor_rules.stage_1.tmp cc_anchor_rules.stage_1
|
||||
mv cc_anchor_rules.stage_1.tmp cc_anchor_rules.stage_1
|
||||
cd ${TmpDir}
|
||||
done
|
||||
|
||||
|
|
@ -496,9 +496,9 @@ convert() {
|
|||
cd ${TmpDir}
|
||||
lgout -n "]"
|
||||
done
|
||||
|
||||
|
||||
cd $CurrentDir
|
||||
|
||||
|
||||
# Copy cascaded style sheet (CSS) file
|
||||
# -------------------------------------------------------
|
||||
lgout -n "copying CSS file"
|
||||
|
|
@ -527,7 +527,7 @@ convert() {
|
|||
fi
|
||||
# copy user images first
|
||||
ImageFiles=`\cat *.html | cc_extract_images | \sort | \uniq`
|
||||
|
||||
|
||||
for f in $ImageFiles ; do
|
||||
ImageSearchPath="."
|
||||
if [ ! -r ${CurrentDir}/${dir}/${f} ]; then
|
||||
|
|
@ -537,7 +537,7 @@ convert() {
|
|||
ImageBase=${f##*/}
|
||||
# relative path, can be empty. If not empty, trailing '/'.
|
||||
ImagePath=${f%$ImageBase}
|
||||
if [ "$ImagePath" != "" ]; then
|
||||
if [ "$ImagePath" != "" ]; then
|
||||
if [ ! -d $ImagePath ]; then ${MakePath} ${ImagePath} ; fi
|
||||
if [ ! -d $ImagePath ]; then
|
||||
error noexit "failed to create directory for image '$f'."
|
||||
|
|
@ -646,7 +646,7 @@ fi
|
|||
# Parse command line parameters
|
||||
# -----------------------------
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
if [ $# -eq 0 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -654,7 +654,7 @@ InFiles=""
|
|||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
|
@ -676,60 +676,60 @@ while [ $# -gt 0 ]; do
|
|||
;;
|
||||
-config)
|
||||
shift
|
||||
if [[ $# -lt 1 || ! -d $1 ]]; then
|
||||
if [[ $# -lt 1 || ! -d $1 ]]; then
|
||||
error_usage 1 "-config needs a valid directory as parameter."
|
||||
fi
|
||||
ConfigPath="$1"
|
||||
;;
|
||||
-tmp)
|
||||
shift
|
||||
if [[ $# -lt 1 || ! -d $1 ]]; then
|
||||
if [[ $# -lt 1 || ! -d $1 ]]; then
|
||||
error_usage 1 "-tmp needs a valid directory as parameter."
|
||||
fi
|
||||
TmpPath="$1"
|
||||
;;
|
||||
-o)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-o needs an additional parameter."
|
||||
fi
|
||||
if [ ! -d $1 ]; then ${MakePath} $1 ; fi
|
||||
if [ ! -d $1 ]; then
|
||||
if [ ! -d $1 ]; then
|
||||
error_usage 1 "-o needs a directory as parameter. Cannot create it."
|
||||
fi
|
||||
OutDir="$1"
|
||||
;;
|
||||
-header | -cgal_dir) # -cgal_dir remains for backwards compatibility
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-header needs an additional parameter."
|
||||
fi
|
||||
CppHeader="-header $1"
|
||||
;;
|
||||
-date)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-date needs an additional parameter."
|
||||
fi
|
||||
LATEX_CONV_DATE="$1"
|
||||
;;
|
||||
-release)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-release needs an additional parameter."
|
||||
fi
|
||||
LATEX_CONV_RELEASE="$1"
|
||||
;;
|
||||
-title)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-title needs an additional parameter."
|
||||
fi
|
||||
LATEX_CONV_TITLE="$1"
|
||||
;;
|
||||
-author)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-author needs an additional parameter."
|
||||
fi
|
||||
LATEX_CONV_AUTHOR="$1"
|
||||
|
|
@ -752,7 +752,7 @@ while [ $# -gt 0 ]; do
|
|||
;;
|
||||
-sty)
|
||||
shift
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -lt 1 ]; then
|
||||
error_usage 1 "-sty needs an additional parameter."
|
||||
fi
|
||||
ExtractOptions = "$ExtractOptions -sty $1"
|
||||
|
|
@ -803,7 +803,7 @@ ConfigGif="${ConfigPath}/gif"
|
|||
# ---------------------------------------------------------------
|
||||
if [ "$OutDir" == "html" ]; then
|
||||
if [ ! -d $OutDir ]; then ${MakePath} $OutDir ; fi
|
||||
if [ ! -d $OutDir ]; then
|
||||
if [ ! -d $OutDir ]; then
|
||||
error_usage 1 "Cannot create default output directory './html/' ."
|
||||
fi
|
||||
fi
|
||||
|
|
@ -834,7 +834,7 @@ TmpDir=$PWD
|
|||
cd ${CurrentDir}
|
||||
|
||||
# convert two path variables for use with Cygwin
|
||||
if eval cygpath -i > /dev/null 2>&1 ; then
|
||||
if eval cygpath -i > /dev/null 2>&1 ; then
|
||||
TmpDir=`cygpath -m $TmpDir`
|
||||
LATEX_CONV_CONFIG=`cygpath -m $LATEX_CONV_CONFIG`
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
#include <iostream>
|
||||
#include <mstring.h>
|
||||
#include <cassert>
|
||||
#include "regex++.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int maxgroups = 20;
|
||||
|
||||
vector<string>
|
||||
Regular_expression::submatch(maxgroups);
|
||||
|
||||
|
||||
Regular_expression::Regular_expression( const char* rx )
|
||||
{ init( rx ); }
|
||||
|
||||
Regular_expression::Regular_expression( const string& rx )
|
||||
{ init( rx.c_str() ); }
|
||||
|
||||
void
|
||||
Regular_expression::init( const char* rx ) {
|
||||
assert( rx != NULL );
|
||||
if( regcomp( ®ex, rx, REG_EXTENDED ) != REG_NOERROR ) {
|
||||
std::cout << "!! Error: regex compilation error" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
regmatch = ( regmatch_t* ) malloc ( maxgroups * sizeof ( regmatch_t ) );
|
||||
assert( regmatch != NULL );
|
||||
}
|
||||
|
||||
Regular_expression::~Regular_expression() {
|
||||
if( regmatch != NULL ) {
|
||||
regfree ( ®ex );
|
||||
free ( regmatch );
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Regular_expression::match( const string& s ) {
|
||||
assert( regmatch != NULL );
|
||||
if( regexec( ®ex, s.c_str(), maxgroups, regmatch, 0 ) == REG_NOERROR ) {
|
||||
int so, eo;
|
||||
for ( unsigned int i = 0; i < maxgroups; i++ ) {
|
||||
so = regmatch[ i ].rm_so;
|
||||
eo = regmatch[ i ].rm_eo;
|
||||
if ( so != -1 )
|
||||
submatch[ i ] = s.substr ( so, eo - so );
|
||||
else
|
||||
submatch[ i ] = "";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Regular_expression::match( const char *s )
|
||||
{ return Regular_expression::match( string( s ) ); }
|
||||
|
||||
const string&
|
||||
Regular_expression::get_match( unsigned int num ) {
|
||||
static string emptystring;
|
||||
if( num >= maxgroups ) {
|
||||
std::cerr << "!! warning: accessing bad regex submatch #" << num << std::endl;
|
||||
return emptystring;
|
||||
}
|
||||
|
||||
return submatch[num];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef REGEXPP_H
|
||||
#define REGEXPP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include <mstring.h>
|
||||
#include <vector>
|
||||
|
||||
struct Regular_expression {
|
||||
struct Exception {};
|
||||
Regular_expression() : regmatch(NULL) {}
|
||||
Regular_expression( const string& rx );
|
||||
Regular_expression( const char* rx );
|
||||
~Regular_expression();
|
||||
|
||||
void init( const char *rx );
|
||||
|
||||
bool match( const string& s );
|
||||
bool match( const char* s );
|
||||
|
||||
static const string& get_match( unsigned int num );
|
||||
protected:
|
||||
|
||||
static vector <string> submatch;
|
||||
regex_t regex;
|
||||
regmatch_t *regmatch;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#include <regex_dictionary.h>
|
||||
#include <regex++.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef hash_map< string, Regular_expression > Regex_map;
|
||||
|
||||
static Regex_map regex_map;
|
||||
|
||||
void
|
||||
regex_register( const string& name, const string ®ex ) {
|
||||
regex_map[name].init( regex.c_str() );
|
||||
//std::cerr << "!! Warning: registered name=[" << name << "] regex=[" << regex << "]" << std::endl;
|
||||
}
|
||||
|
||||
bool
|
||||
regex_does_match( const string& name, const string& text ) {
|
||||
bool result = regex_map[name].match( text );
|
||||
std::cerr << "!! checking " << name << " against " << text << " yields: " << result << std::endl;
|
||||
std::cerr << "match1 : " << regex_get_submatch(1) << std::endl;
|
||||
std::cerr << "match2 : " << regex_get_submatch(2) << std::endl;
|
||||
std::cerr << "match3 : " << regex_get_submatch(3) << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
const string&
|
||||
regex_get_submatch( unsigned int num ) {
|
||||
return Regular_expression::get_match( num );
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef REGEX_DICTIONARY_H
|
||||
#define REGEX_DICTIONARY_H
|
||||
|
||||
#include <mstring.h>
|
||||
|
||||
void regex_register( const string& name, const string ®ex );
|
||||
bool regex_does_match( const string& name, const string& text );
|
||||
const string& regex_get_submatch( unsigned int num );
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue