diff --git a/development/FORMAT b/development/FORMAT index 084faaf20d..cd66ae7235 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be ----------------------- +2019-06-23 Jürgen Spitzmüller + * Format incremented to 578: Add support for Discourse Representation Structures + in the Linguistics module (using drs package). + 2019-06-04 Jürgen Spitzmüller * Format incremented to 577: Rework linguistic gloss support. This now uses the covington 2.0 gloss macros (\digloss, \trigloss) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index dbdb7ed449..970b26baaa 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -305,6 +305,7 @@ \TestPackage{covington} \TestPackage{cprotect} \TestPackage{csquotes} +\TestPackage{drs} \TestPackage[koi8-r.def]{cyrillic} \TestPackage{dvipost} \TestPackage{endnotes} @@ -363,6 +364,7 @@ \TestPackage{pdfcomment} \TestPackage{pdfpages} \TestPackage{pgf} % required by tcolorbox +\TestPackage{pict2e} \TestPackage{prettyref} \TestPackage{preview} \TestPackage{refstyle} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index af70dd91b7..8ad9a5b318 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 566 +\lyxformat 578 \begin_document \begin_header \save_transient_properties true @@ -53,6 +53,7 @@ \justification true \use_refstyle 0 \use_minted 0 +\use_lineno 0 \index Index \shortcut idx \color #008000 @@ -68,6 +69,7 @@ \papercolumns 1 \papersides 1 \paperpagestyle plain +\tablestyle default \tracking_changes true \output_changes false \html_math_output 0 @@ -76,6 +78,7 @@ \html_latex_start \html_latex_end \author -1402925745 "Günter Milde" +\author -712698321 "Jürgen Spitzmüller" \end_header \begin_body @@ -6477,6 +6480,50 @@ csquotes provides context-sensitive quotation marks that adapt to the conventions of the actual document language. It is used by the Linguistics module for the character style Meaning. +\change_inserted -712698321 1561287288 + +\end_layout + +\begin_layout Subsubsection + +\change_inserted -712698321 1561287293 +drs +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287288 +Found: +\begin_inset Info +type "package" +arg "drs" +\end_inset + + +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287316 +CTAN: +\family typewriter +macros/latex/contrib/drs/ +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287342 +Notes: The package +\family sans +drs +\family default + provides some commands for +\emph on +Discourse Representation Structures +\emph default +. +\change_unchanged + \end_layout \begin_layout Subsubsection @@ -6538,6 +6585,54 @@ Notes: The package forest \family default provides support for generating linguistic structure trees. +\change_inserted -712698321 1561287358 + +\end_layout + +\begin_layout Subsubsection + +\change_inserted -712698321 1561287365 +pict2e +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287358 +Found: +\begin_inset Info +type "package" +arg "pict2e" +\end_inset + + +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287390 +CTAN: +\family typewriter +macros/latex/contrib/ +\family default +pict2e +\family typewriter +/ +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1561287426 +Notes: The package +\family sans +pict2e +\family default + is used for +\emph on +Duplex Condition DRS +\emph default +es. +\change_unchanged + \end_layout \begin_layout Subsection diff --git a/lib/examples/Modules/Linguistics.lyx b/lib/examples/Modules/Linguistics.lyx index 063b0ae00f..ec211c332a 100644 --- a/lib/examples/Modules/Linguistics.lyx +++ b/lib/examples/Modules/Linguistics.lyx @@ -154,8 +154,11 @@ This paper describes some features that \SpecialChar LyX \change_inserted -712698321 1559649291 interlinear \change_unchanged -glosses, OT tableaux, semantic markup, structure trees, and phonetic symbols - (IPA). +glosses, OT tableaux, semantic markup, structure trees, +\change_inserted -712698321 1561275938 +Discourse Representation Structures, +\change_unchanged +and phonetic symbols (IPA). \end_layout \begin_layout Section @@ -262,6 +265,8 @@ arg "covington" \end_inset . +\change_inserted -712698321 1561275950 + \end_layout \end_deeper @@ -347,6 +352,48 @@ arg "csquotes" \end_inset . +\change_inserted -712698321 1561276155 + +\end_layout + +\end_deeper +\begin_layout Enumerate + +\change_inserted -712698321 1561276156 + +\emph on +drs.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "drs" +literal "true" + +\end_inset + +: Needed for +\emph on +Discourse Representation Structures +\emph default +. + Note that at least version 2.3 of the covington package is required if you + use DRS with covington features. +\end_layout + +\begin_deeper +\begin_layout Itemize + +\change_inserted -712698321 1561276156 +Installed on your system: +\begin_inset Info +type "package" +arg "drs" +\end_inset + +. +\change_unchanged + \end_layout \end_deeper @@ -405,6 +452,46 @@ arg "forest" \end_inset . +\change_inserted -712698321 1561276162 + +\end_layout + +\end_deeper +\begin_layout Enumerate + +\change_inserted -712698321 1561276195 + +\emph on +pict2e.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "pict2e" +literal "true" + +\end_inset + +: Needed for +\emph on +Duplex Condition DRS +\emph default +es. +\end_layout + +\begin_deeper +\begin_layout Itemize + +\change_inserted -712698321 1561276163 +Installed on your system: +\begin_inset Info +type "package" +arg "pict2e" +\end_inset + +. +\change_unchanged + \end_layout \end_deeper @@ -2674,6 +2761,727 @@ literal "true" ). \end_layout +\begin_layout Section + +\change_inserted -712698321 1561276366 +Discourse Representation Structures +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561276535 +The linguistics module provides some insets to draw +\emph on +Discourse Representation Structures +\emph default + (DRSes) in the box notation introduced in +\noun on +Hans Kamp +\noun default +'s +\emph on +Discourse Representation Theory +\emph default +. + These insets can be found in +\family sans +Insert\SpecialChar menuseparator +Custom Insets +\family default +. +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561282371 +A simple DRS is produced by +\family sans +Discourse Representation Structure +\family default +. + A DRS consists of the +\emph on +conditions +\emph default +, which have to be inserted into the inset directly and the (possibly empty) + +\emph on +referents +\emph default + (or +\emph on +universe +\emph default + in DRTese), which have to be input in the (automatically inserted) +\emph on +Referents +\emph default + sub-inset. +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1561276845 +If it is not inserted, you can also insert it via +\family sans +Insert\SpecialChar menuseparator +DRS Referents +\family default +. +\change_unchanged + +\end_layout + +\end_inset + + Line breaks in conditions need to be done via +\begin_inset Info +type "shortcut" +arg "newline-insert newline" +\end_inset + +. + Here is a simple example: +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561277426 +\begin_inset VSpace defskip +\end_inset + + +\begin_inset Flex DRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561276618 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561276576 +x +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561277217 +donkey(x) +\begin_inset Newline newline +\end_inset + +green(x) +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561278779 +\begin_inset VSpace defskip +\end_inset + +DRSes get some extra spacing for better positioning on the page. + The +\family sans +unspaced +\family default + variant comes without this extra spacing. +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561282534 +In addition to this simple DRS, the following conditional DRSes are provided + (mainly for nesting into simple DRSes): +\end_layout + +\begin_layout Enumerate + +\change_inserted -712698321 1561282617 +The +\family sans +If-Then DRS +\family default + represents a conditional (implicational) sentence constructions of the + form +\emph on +if S +\begin_inset script subscript + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279387 + +\emph off +1 +\change_unchanged + +\end_layout + +\end_inset + + then S +\emph default + +\begin_inset script subscript + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279395 +2 +\change_unchanged + +\end_layout + +\end_inset + +: +\end_layout + +\begin_deeper +\begin_layout Standard + +\change_inserted -712698321 1561279897 +\begin_inset Flex IfThen-DRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279544 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280450 +x +\begin_inset space ~ +\end_inset + +y +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280496 +John(x) +\begin_inset Newline newline +\end_inset + +donkey(y) +\begin_inset Newline newline +\end_inset + +own(x,y) +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279603 +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279599 +z +\begin_inset space ~ +\end_inset + +w +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279579 +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280579 +z = x +\begin_inset Newline newline +\end_inset + +w = y +\begin_inset Newline newline +\end_inset + +feed(z,w) +\change_unchanged + +\end_layout + +\end_inset + + +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate + +\change_inserted -712698321 1561282668 +The +\family sans +Conditional DRS +\family default + is a more general case where you can specify an arbitrary condition (rather + than using the implicational condition). + You can insert any symbol in the condition sub-inset: +\end_layout + +\begin_deeper +\begin_layout Standard + +\change_inserted -712698321 1561281161 +\begin_inset Flex Cond-DRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280361 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280351 +x +\begin_inset space ~ +\end_inset + +y +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280787 +John(x) +\begin_inset Newline newline +\end_inset + +donkey(y) +\begin_inset Newline newline +\end_inset + +own(x,y) +\change_unchanged + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279982 +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280653 +\begin_inset Formula $\wedge\!\,$ +\end_inset + + +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279982 +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280702 +z +\begin_inset space ~ +\end_inset + +w +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561279982 +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561280703 +z = x +\begin_inset Newline newline +\end_inset + +w = y +\begin_inset Newline newline +\end_inset + +love(w,z) +\change_unchanged + +\end_layout + +\end_inset + + +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate + +\change_inserted -712698321 1561281199 +The +\family sans +Duplex Condition DRS +\family default + can be used to insert duplex conditions: +\end_layout + +\begin_deeper +\begin_layout Standard + +\change_inserted -712698321 1561281613 +\begin_inset Flex QDRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281297 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281237 +x +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281305 +x +\begin_inset Formula $\in$ +\end_inset + + X +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281209 +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281317 +every +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281209 +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281320 +x +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281209 +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281327 +y +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281209 +\begin_inset Argument post:4 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561282714 +secretary(y) +\begin_inset Newline newline +\end_inset + +hire(x,y) +\change_unchanged + +\end_layout + +\end_inset + + +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate + +\change_inserted -712698321 1561281636 +The +\family sans +Negated DRS +\family default + adds a DRS preceded by a negation symbol: +\end_layout + +\begin_deeper +\begin_layout Standard + +\change_inserted -712698321 1561281719 +\begin_inset Flex NegDRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281667 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281667 +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281697 +donkey(x) +\begin_inset Newline newline +\end_inset + +green(x) +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Standard + +\change_inserted -712698321 1561281800 +Finally, +\family sans +DRS with Sentence above +\family default + lets you do what it promises: adding a sentence above the box representation: +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561282183 +\begin_inset VSpace defskip +\end_inset + + +\begin_inset Flex SDRS +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281911 +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281859 +A donkey is green +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281886 +\begin_inset Argument 2 +status open + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281888 +x +\change_unchanged + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\change_inserted -712698321 1561281854 +donkey(x) +\begin_inset Newline newline +\end_inset + +green(x) +\change_unchanged + +\end_layout + +\end_inset + + +\begin_inset VSpace defskip +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted -712698321 1561282246 +The +\emph on +drs +\emph default + package provides some means to customize the layout and appearance of the + DRS boxes. + Please refer to the package manual +\begin_inset CommandInset citation +LatexCommand cite +key "drs" +literal "false" + +\end_inset + + for details. +\change_unchanged + +\end_layout + \begin_layout Section Phonetic Symbols (IPA) \end_layout @@ -3096,6 +3904,40 @@ http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/ \end_inset . +\change_inserted -712698321 1561276082 + +\end_layout + +\begin_layout Bibliography + +\change_inserted -712698321 1561276305 +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "drs" +literal "false" + +\end_inset + + The drs +\emph on + +\emph default +package: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1561282286 + +https://ctan.org/tex-archive/macros/latex/contrib/drs +\end_layout + +\end_inset + +. +\change_unchanged + \end_layout \begin_layout Bibliography @@ -3187,6 +4029,38 @@ https://wiki.lyx.org/LyX/LinguistLyX \end_inset . +\change_inserted -712698321 1561276282 + +\end_layout + +\begin_layout Bibliography + +\change_inserted -712698321 1561276302 +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "pict2e" +literal "false" + +\end_inset + +The pict2e package: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1561276288 + +https://ctan.org/tex-archive/macros/latex/contrib/pict2e +\change_unchanged + +\end_layout + +\end_inset + + +\change_unchanged + \end_layout \begin_layout Bibliography diff --git a/lib/layouts/linguistics.module b/lib/layouts/linguistics.module index f83f2b629a..352e9e4463 100644 --- a/lib/layouts/linguistics.module +++ b/lib/layouts/linguistics.module @@ -1,4 +1,4 @@ -#\DeclareLyXModule[covington.sty,forest.sty]{Linguistics} +#\DeclareLyXModule[covington.sty,drs.sty,forest.sty,pict2e.sty]{Linguistics} #\DeclareCategory{Academic Field Specifics} #DescriptionBegin #Defines some special environments useful for linguistics (numbered examples, @@ -250,6 +250,182 @@ InsetLayout Flex:Structure_Tree End +# +# Discourse Representation Structures +# + +InsetLayout Flex:DRS + LyXType custom + LabelString DRS + MenuString "Discourse Representation Structure|D" + LatexType command + LatexName drs + Decoration classic + MultiPar true + CustomPars false + ParbreakIsNewline true + FreeSpacing true + Requires drs + ResetsFont true + Argument 1 + Decoration conglomerate + LabelString "Referents" + MenuString "DRS Referents" + Tooltip "Add the DRS referents (universe) here" + Mandatory true + AutoInsert true + EndArgument +End + + +InsetLayout Flex:DRS* + CopyStyle Flex:DRS + LabelString DRS* + MenuString "Discourse Representation Structure (unspaced)|u" + LatexName drs* +End + + +InsetLayout Flex:IfThen-DRS + CopyStyle Flex:DRS + LabelString "If-Then DRS" + MenuString "If-Then DRS" + LatexName ifdrs + Argument post:1 + Decoration classic + LabelString "Then-Referents" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-referents (universe) here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:2 + Decoration classic + LabelString "Then-Conditions" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-conditions here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument +End + + +InsetLayout Flex:Cond-DRS + CopyStyle Flex:DRS + LabelString "Cond. DRS" + MenuString "Conditional DRS" + LatexName condrs + Argument post:1 + Decoration classic + LabelString "Cond." + MenuString "DRS Condition" + Tooltip "Add the DRS condition here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:2 + Decoration classic + LabelString "Then-Referents" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-referents (universe) here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:3 + Decoration classic + LabelString "Then-Conditions" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-conditions here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument +End + + +InsetLayout Flex:QDRS + CopyStyle Flex:DRS + LabelString "Dupl. Cond. DRS" + MenuString "Duplex Condition DRS" + LatexName qdrs + Argument post:1 + Decoration classic + LabelString "Quant." + MenuString "DRS Quantifier" + Tooltip "Add the DRS duplex quantifier here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:2 + Decoration classic + LabelString "Quant. Var." + MenuString "DRS Quantifier Variable" + Tooltip "Add the DRS duplex quantifier variables here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:3 + Decoration classic + LabelString "Then-Referents" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-referents (universe) here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument post:4 + Decoration classic + LabelString "Then-Conditions" + MenuString "DRS Then-Referents" + Tooltip "Add the DRS then-conditions here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Requires drs,pict2e +End + + +InsetLayout Flex:NegDRS + CopyStyle Flex:DRS + LabelString "Neg. DRS" + MenuString "Negated DRS" + LatexName negdrs +End + + +InsetLayout Flex:SDRS + CopyStyle Flex:DRS + LabelString "Sent. DRS" + MenuString "DRS with Sentence above" + LatexName sdrs + Argument 1 + Decoration conglomerate + LabelString "Sentence" + MenuString "DRS Sentence" + Tooltip "Add the sentence here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument + Argument 2 + Decoration conglomerate + LabelString "Referents" + MenuString "DRS Referents" + Tooltip "Add the DRS referents (universe) here" + Mandatory true + AutoInsert true + InsertOnNewline true + EndArgument +End + + # # Semantic Markup # diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index 29e08aedc8..dd32314342 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -1841,7 +1841,7 @@ def revert_linggloss(document): return cov_req = False - glosses = ("\\begin_inset Flex Interlinear Gloss (2 Lines)", "\\begin_inset Flex Interlinear Gloss (3 Lines)") + glosses = ["\\begin_inset Flex Interlinear Gloss (2 Lines)", "\\begin_inset Flex Interlinear Gloss (3 Lines)"] for glosse in glosses: i = 0 while True: @@ -2032,6 +2032,217 @@ def revert_subexarg(document): i += 1 +def revert_drs(document): + " Revert DRS insets (linguistics) to ERT " + + if not "linguistics" in document.get_module_list(): + return + + cov_req = False + drses = ["\\begin_inset Flex DRS", "\\begin_inset Flex DRS*", + "\\begin_inset Flex IfThen-DRS", "\\begin_inset Flex Cond-DRS", + "\\begin_inset Flex QDRS", "\\begin_inset Flex NegDRS", + "\\begin_inset Flex SDRS"] + for drs in drses: + i = 0 + while True: + i = find_token(document.body, drs, i) + if i == -1: + break + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + # Check for arguments + arg = find_token(document.body, "\\begin_inset Argument 1", i, j) + endarg = find_end_of_inset(document.body, arg) + prearg1content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument 1 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + prearg1content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # re-find inset end + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + arg = find_token(document.body, "\\begin_inset Argument 2", i, j) + endarg = find_end_of_inset(document.body, arg) + prearg2content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument 2 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + prearg2content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # re-find inset end + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + arg = find_token(document.body, "\\begin_inset Argument post:1", i, j) + endarg = find_end_of_inset(document.body, arg) + postarg1content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument post:1 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + postarg1content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # re-find inset end + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + arg = find_token(document.body, "\\begin_inset Argument post:2", i, j) + endarg = find_end_of_inset(document.body, arg) + postarg2content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument post:2 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + postarg2content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # re-find inset end + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + arg = find_token(document.body, "\\begin_inset Argument post:3", i, j) + endarg = find_end_of_inset(document.body, arg) + postarg3content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument post:3 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + postarg3content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # re-find inset end + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Malformed LyX document: Can't find end of DRS inset") + i += 1 + continue + + arg = find_token(document.body, "\\begin_inset Argument post:4", i, j) + endarg = find_end_of_inset(document.body, arg) + postarg4content = [] + if arg != -1: + argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg) + if argbeginPlain == -1: + document.warning("Malformed LyX document: Can't find Argument post:4 plain Layout") + i += 1 + continue + argendPlain = find_end_of_inset(document.body, argbeginPlain) + postarg4content = document.body[argbeginPlain + 1 : argendPlain - 2] + + # remove Arg insets and paragraph, if it only contains this inset + if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3: + del document.body[arg - 1 : endarg + 4] + else: + del document.body[arg : endarg + 1] + + # The respective LaTeX command + cmd = "\\drs" + if drs == "\\begin_inset Flex DRS*": + cmd = "\\drs*" + elif drs == "\\begin_inset Flex IfThen-DRS": + cmd = "\\ifdrs" + elif drs == "\\begin_inset Flex Cond-DRS": + cmd = "\\condrs" + elif drs == "\\begin_inset Flex QDRS": + cmd = "\\qdrs" + elif drs == "\\begin_inset Flex NegDRS": + cmd = "\\negdrs" + elif drs == "\\begin_inset Flex SDRS": + cmd = "\\sdrs" + + beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i) + endInset = find_end_of_inset(document.body, i) + endPlain = find_token_backwards(document.body, "\\end_layout", endInset) + precontent = put_cmd_in_ert(cmd) + precontent += put_cmd_in_ert("{") + prearg1content + put_cmd_in_ert("}") + if drs == "\\begin_inset Flex SDRS": + precontent += put_cmd_in_ert("{") + prearg2content + put_cmd_in_ert("}") + precontent += put_cmd_in_ert("{") + + postcontent = [] + if cmd == "\\qdrs" or cmd == "\\condrs" or cmd == "\\ifdrs": + postcontent = put_cmd_in_ert("}{") + postarg1content + put_cmd_in_ert("}{") + postarg2content + put_cmd_in_ert("}") + if cmd == "\\condrs" or cmd == "\\qdrs": + postcontent += put_cmd_in_ert("{") + postarg3content + put_cmd_in_ert("}") + if cmd == "\\qdrs": + postcontent += put_cmd_in_ert("{") + postarg4content + put_cmd_in_ert("}") + else: + postcontent = put_cmd_in_ert("}") + + document.body[endPlain:endInset + 1] = postcontent + document.body[beginPlain + 1:beginPlain] = precontent + del document.body[i : beginPlain + 1] + if not cov_req: + document.append_local_layout("Provides covington") + add_to_preamble(document, ["\\usepackage{drs,covington}"]) + cov_req = True + i = beginPlain + 1 + + ## # Conversion hub # @@ -2070,10 +2281,12 @@ convert = [ [574, [convert_ruby_module, convert_utf8_japanese]], [575, [convert_lineno]], [576, []], - [577, [convert_linggloss]] + [577, [convert_linggloss]], + [578, []] ] -revert = [[576, [revert_linggloss, revert_subexarg]], +revert = [[576, [revert_drs]], + [576, [revert_linggloss, revert_subexarg]], [575, [revert_new_languages]], [574, [revert_lineno]], [573, [revert_ruby_module, revert_utf8_japanese]], diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index d4c6d5e29b..4abb586f22 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -998,7 +998,9 @@ char const * simplefeatures[] = { "tabularx", "xltabular", "chessboard", - "xskak" + "xskak", + "pict2e", + "drs" }; char const * bibliofeatures[] = { diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index b93e4cc766..203ad22bf8 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -35,10 +35,17 @@ Format LaTeX feature LyX feature 453 automatic stmaryrd loading \use_package stmaryrd 457 automatic stackrel loading \use_package stackrel 575 numbering of lines (lineno) \use_lineno, \lineno_options -577 new covington gloss macros - \digloss[opt]{one}{two}{three} \begin_inset Flex Interlinear Gloss (2 Lines) (Argument 1, Argument post:1, Argument:post 2) - \trigloss[opt]{one}{two}{three}{four} \begin_inset Flex Interlinear Gloss (3 Lines) (Argument 1, Argument post:1, Argument:post 2, Argument:post 3) - +577 new covington gloss macros (Linguistics module) + \digloss[opt]{one}{two}{three} \begin_inset Flex Interlinear Gloss (2 Lines) (Argument 1, Argument post:1, Argument post:2) + \trigloss[opt]{one}{two}{three}{four} \begin_inset Flex Interlinear Gloss (3 Lines) (Argument 1, Argument post:1, Argument post:2, Argument post:3) +578 Discourse Representation Structures (Linguistics module) + \drs{arg1}{content} \begin_inset Flex DRS (Argument 1) + \drs*{arg1}{content} \begin_inset Flex DRS* (Argument 1) + \ifdrs{arg1}{content}{post1}{post2} \begin_inset Flex IfThen-DRS (Argument 1, Argument post:1, Argument post:2) + \condrs{arg1}{content}{post1}{post2}{post3} \begin_inset Flex Cond-DRS (Argument 1, Argument post:1, Argument post:2, Argument post:3) + \qdrs{arg1}{content}{post1}{post2}{post3}{post4} \begin_inset Flex QDRS (Argument 1, Argument post:1, Argument post:2, Argument post:3, Argument post:4) + \negdrs{arg1}{content} \begin_inset Flex NegDRS (Argument 1) + \sdrs{arg1}[arg2}{content} \begin_inset Flex SDRS (Argument 1, Argument 2) General diff --git a/src/version.h b/src/version.h index 61d5ee6b34..ce41bf00a9 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 577 // spitz: new ling glosses -#define LYX_FORMAT_TEX2LYX 577 +#define LYX_FORMAT_LYX 578 // spitz: drs +#define LYX_FORMAT_TEX2LYX 578 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER