From c32a937eb953251ed4b1ed015b2513b569636b5b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 22 Mar 2019 18:29:50 +0100 Subject: [PATCH] Add soul module --- development/FORMAT | 6 ++- lib/Makefile.am | 1 + lib/layouts/soul.module | 88 +++++++++++++++++++++++++++++++++++++++++ lib/lyx2lyx/lyx_2_4.py | 26 +++++++++++- src/tex2lyx/TODO.txt | 8 +++- src/version.h | 4 +- 6 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 lib/layouts/soul.module diff --git a/development/FORMAT b/development/FORMAT index a568b44bc5..2bbab73ed9 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,8 +7,12 @@ changes happened in particular if possible. A good example would be ----------------------- +2019-03-22 Jürgen Spitzmüller + * format incremented to 568: Support for the soul module: + \so, \hl, \st, \ul, \caps + 2019-02-21 Joice Joseph - * Format incremented to 567: Support for Malayalam: + * Format incremented to 567: Support for Malayalam: \lang malayalam 2018-10-29 Guy Rutenberg diff --git a/lib/Makefile.am b/lib/Makefile.am index 94aa898d2c..5dd2d902bf 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2409,6 +2409,7 @@ dist_layouts_DATA =\ layouts/singlecol.layout \ layouts/singlecol-new.layout \ layouts/slides.layout \ + layouts/soul.module \ layouts/spie.layout \ layouts/stdciteformats.inc \ layouts/stdclass.inc \ diff --git a/lib/layouts/soul.module b/lib/layouts/soul.module new file mode 100644 index 0000000000..252dd5ea39 --- /dev/null +++ b/lib/layouts/soul.module @@ -0,0 +1,88 @@ +#\DeclareLyXModule[soul.sty]{Soul Text Markup} +#DescriptionBegin +#Defines text styles to highlight, space-out, strike-through +#underline and capitalize text by means of the soul package. +#DescriptionEnd +#Requires +#Excludes + +#Author: Stephen [original implementation], +# Juergen Spitzmueller [fixes] + +Format 71 + +InsetLayout Flex:Spaceletters + LyxType charstyle + LabelString spaced + Decoration conglomerate + LatexType command + LatexName so + LabelFont + Size Small + EndFont + NeedMBoxProtect true + MultiPar true + Requires soul +End + +InsetLayout Flex:Strikethrough + CopyStyle Flex:Spaceletters + LabelString strike + LatexName st + Font + Misc strikeout + EndFont +End + +InsetLayout Flex:Underline + CopyStyle Flex:Spaceletters + LabelString ul + LatexName ul + Font + Misc underbar + EndFont +End + +InsetLayout Flex:Highlight + CopyStyle Flex:Spaceletters + LabelString hl + LatexName hl + BgColor yellow + Requires soul,color +End + +InsetLayout Flex:Capitalize + CopyStyle Flex:Spaceletters + LabelString caps + LatexName caps + Font + Shape smallcaps + EndFont +End + + +# Obsolete older forms used on wiki.lyx.org + +InsetLayout Flex:spaceletters + ObsoletedBy Flex:Spaceletters +End + +InsetLayout Flex:strikethrough + ObsoletedBy Flex:Strikethrough +End + +InsetLayout Flex:underline + ObsoletedBy Flex:Underline +End + +InsetLayout Flex:highlight + ObsoletedBy Flex:Highlight +End + +InsetLayout Flex:capitalise + ObsoletedBy Flex:Capitalize +End + +InsetLayout Flex:Capitalise + ObsoletedBy Flex:Capitalize +End diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index cf68d70a34..6b3858e6a8 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -36,7 +36,7 @@ from parser_tools import (count_pars_in_inset, find_end_of_inset, find_end_of_la # is_in_inset, set_bool_value # find_tokens, find_token_exact, check_token -from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, revert_language) +from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, revert_language, revert_flex_inset) # revert_font_attrs, insert_to_preamble, latex_length # get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets # revert_flex_inset, hex2ratio, str2bool @@ -1413,6 +1413,28 @@ def revert_malayalam(document): revert_language(document, "malayalam", "", "malayalam") +def revert_soul(document): + " Revert soul module flex insets to ERT " + + flexes = ["Spaceletters", "Strikethrough", "Underline", "Highlight", "Capitalize"] + + for flex in flexes: + i = find_token(document.body, "\\begin_inset Flex %s" % flex, 0) + if i != -1: + add_to_preamble(document, ["\\usepackage{soul}"]) + break + i = find_token(document.body, "\\begin_inset Flex Highlight", 0) + if i != -1: + add_to_preamble(document, ["\\usepackage{color}"]) + + revert_flex_inset(document.body, "Spaceletters", "\\so") + revert_flex_inset(document.body, "Strikethrough", "\\st") + revert_flex_inset(document.body, "Underline", "\\ul") + revert_flex_inset(document.body, "Highlight", "\\hl") + revert_flex_inset(document.body, "Capitalize", "\\caps") + + + ## # Conversion hub # @@ -1442,9 +1464,11 @@ convert = [ [565, [convert_AdobeFonts]], # Handle adobe fonts in GUI [566, [convert_hebrew_parentheses]], [567, []], + [568, []] ] revert = [ + [567, [revert_soul]], [566, [revert_malayalam]], [565, [revert_hebrew_parentheses]], [564, [revert_AdobeFonts]], diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 365e7915db..d813c064fe 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -34,7 +34,13 @@ Format LaTeX feature LyX feature 443 unicode-math.sty InsetMath* 453 automatic stmaryrd loading \use_package stmaryrd 457 automatic stackrel loading \use_package stackrel -563 InsetArgument listpreamble:1 All content between \begin{env} and first \item of a list +563 InsetArgument listpreamble:1 All content between \begin{env} and first \item of a list +568 Soul package soul.module + \caps{...} \begin_inset Flex Capitalize + \hl{...} \begin_inset Flex Highlight + \so{...} \begin_inset Flex Spaceletters + \st{...} \begin_inset Flex Strikethrough + \ul{...} \begin_inset Flex Underline diff --git a/src/version.h b/src/version.h index 885b13fa40..cc24a614d8 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 567 // Joice : Added support for malayalam. -#define LYX_FORMAT_TEX2LYX 567 +#define LYX_FORMAT_LYX 568 // spitz :soul.module +#define LYX_FORMAT_TEX2LYX 568 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER -- 2.39.5