2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetERT.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
|
|
|
* \author Lars Gullik Bjønnes
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
2003-11-10 09:06:48 +00:00
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetERT.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2004-11-04 19:50:04 +00:00
|
|
|
#include "FuncStatus.h"
|
2020-12-02 20:34:28 +00:00
|
|
|
#include "InsetLayout.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Language.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2020-06-08 21:27:49 +00:00
|
|
|
#include "xml.h"
|
2005-02-03 17:24:40 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Paragraph.h"
|
2020-12-02 20:34:28 +00:00
|
|
|
#include "output_docbook.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2018-04-02 02:40:00 +00:00
|
|
|
#include "support/docstream.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/gettext.h"
|
2007-11-13 23:50:28 +00:00
|
|
|
#include "support/lstrings.h"
|
2018-04-02 02:40:00 +00:00
|
|
|
#include "support/TempFile.h"
|
2007-11-13 23:50:28 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2000-02-25 12:06:15 +00:00
|
|
|
|
2021-02-19 21:38:25 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetERT::InsetERT(Buffer * buf, CollapseStatus status)
|
2017-10-16 08:12:21 +00:00
|
|
|
: InsetCollapsible(buf)
|
2008-10-26 02:25:57 +00:00
|
|
|
{
|
|
|
|
status_ = status;
|
|
|
|
}
|
2001-07-24 10:13:19 +00:00
|
|
|
|
2001-07-08 12:52:16 +00:00
|
|
|
|
2018-10-04 17:36:01 +00:00
|
|
|
InsetERT::InsetERT(InsetERT const & old)
|
|
|
|
: InsetCollapsible(old)
|
2018-04-02 02:40:00 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetERT::write(ostream & os) const
|
2000-06-28 13:35:52 +00:00
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
os << "ERT" << "\n";
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::write(os);
|
2000-06-28 13:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetERT::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const & rp, size_t max_length) const
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
2009-09-10 12:07:42 +00:00
|
|
|
if (!rp.inIndexEntry)
|
|
|
|
// do not output TeX code
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
while (par != end && os.str().size() <= max_length) {
|
2009-09-10 12:07:42 +00:00
|
|
|
pos_type siz = par->size();
|
|
|
|
for (pos_type i = 0; i < siz; ++i) {
|
|
|
|
char_type const c = par->getChar(i);
|
|
|
|
// output the active characters
|
|
|
|
switch (c) {
|
|
|
|
case '|':
|
|
|
|
case '!':
|
|
|
|
case '@':
|
|
|
|
os.put(c);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++par;
|
|
|
|
}
|
|
|
|
return 0;
|
2001-06-27 14:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-07 02:24:11 +00:00
|
|
|
static const std::map<docstring, docstring> raw_latex_encoding_to_unicode_xml{
|
|
|
|
// Punctuation.
|
|
|
|
{from_ascii("\\textquotesingle"), from_ascii("'")},
|
|
|
|
{from_ascii("!`"), from_ascii("¡")}, // inverted exclamation mark
|
|
|
|
{from_ascii("?`"), from_ascii("¿")}, // inverted interrogation mark
|
|
|
|
|
|
|
|
// Logos.
|
|
|
|
{from_ascii("\\LaTeX"), from_ascii("LaTeX")},
|
|
|
|
{from_ascii("\\LaTeXe"), from_ascii("LaTeX2ε")}, // LaTeX 2 epsilon
|
|
|
|
{from_ascii("\\LyX"), from_ascii("LyX")},
|
|
|
|
{from_ascii("\\TeX"), from_ascii("TeX")},
|
|
|
|
|
|
|
|
// Accentuated letters (alphabetical order of description, ligatures after accents).
|
|
|
|
// Missing letters are only indicated for vowels (only few consonants have diacritics).
|
|
|
|
// Only symbols that can be expressed as one Unicode characters are present; symbols with more than one
|
|
|
|
// diacritic are also omitted.
|
|
|
|
{from_ascii("\\`{a}"), from_ascii("á")}, // a acute
|
|
|
|
{from_ascii("\\` a"), from_ascii("á")},
|
|
|
|
{from_ascii("\\`{A}"), from_ascii("Á")}, // A acute
|
|
|
|
{from_ascii("\\` A"), from_ascii("Á")},
|
|
|
|
{from_ascii("\\u{a}"), from_ascii("ă")}, // a breve
|
|
|
|
{from_ascii("\\u a"), from_ascii("ă")},
|
|
|
|
{from_ascii("\\u{A}"), from_ascii("Ă")}, // A breve
|
|
|
|
{from_ascii("\\u A"), from_ascii("Ă")},
|
|
|
|
{from_ascii("\\v{a}"), from_ascii("ǎ")}, // a caron
|
|
|
|
{from_ascii("\\v a"), from_ascii("ǎ")},
|
|
|
|
{from_ascii("\\v{A}"), from_ascii("Ǎ")}, // A caron
|
|
|
|
{from_ascii("\\v A"), from_ascii("Ǎ")},
|
|
|
|
// No a cedilla.
|
|
|
|
{from_ascii("\\^{a}"), from_ascii("â")}, // a circumflex
|
|
|
|
{from_ascii("\\^ a"), from_ascii("â")},
|
|
|
|
{from_ascii("\\^{A}"), from_ascii("Â")}, // A circumflex
|
|
|
|
{from_ascii("\\^ A"), from_ascii("Â")},
|
|
|
|
{from_ascii("\\\"{a}"), from_ascii("ä")}, // a diaeresis
|
|
|
|
{from_ascii("\\\" a"), from_ascii("ä")},
|
|
|
|
{from_ascii("\\\"{A}"), from_ascii("Ä")}, // A diaeresis
|
|
|
|
{from_ascii("\\\" A"), from_ascii("Ä")},
|
|
|
|
// No a double acute.
|
|
|
|
{from_ascii("\\`{a}"), from_ascii("à")}, // a grave
|
|
|
|
{from_ascii("\\` a"), from_ascii("à")},
|
|
|
|
{from_ascii("\\`{A}"), from_ascii("À")}, // A grave
|
|
|
|
{from_ascii("\\` A"), from_ascii("À")},
|
|
|
|
{from_ascii("\\~{a}"), from_ascii("ã")}, // a tilde
|
|
|
|
{from_ascii("\\~ a"), from_ascii("ã")},
|
|
|
|
{from_ascii("\\~{A}"), from_ascii("Ã")}, // A tilde
|
|
|
|
{from_ascii("\\~ A"), from_ascii("Ã")},
|
|
|
|
{from_ascii("\\aa"), from_ascii("å")}, // a ring
|
|
|
|
{from_ascii("\\r{a}"), from_ascii("å")},
|
|
|
|
{from_ascii("\\r a"), from_ascii("å")},
|
|
|
|
{from_ascii("\\AA"), from_ascii("Å")}, // A ring
|
|
|
|
{from_ascii("\\r{A}"), from_ascii("Å")},
|
|
|
|
{from_ascii("\\r A"), from_ascii("Å")},
|
|
|
|
{from_ascii("\\ae"), from_ascii("æ")}, // ae ligature
|
|
|
|
{from_ascii("\\AE"), from_ascii("Æ")}, // AE ligature
|
|
|
|
{from_ascii("\\v{c}"), from_ascii("č")}, // c caron
|
|
|
|
{from_ascii("\\v c"), from_ascii("č")},
|
|
|
|
{from_ascii("\\v{C}"), from_ascii("Č")}, // C caron
|
|
|
|
{from_ascii("\\v C"), from_ascii("Č")},
|
|
|
|
{from_ascii("\\c{c}"), from_ascii("Ç")}, // c cedilla
|
|
|
|
{from_ascii("\\c c"), from_ascii("Ç")},
|
|
|
|
{from_ascii("\\c{C}"), from_ascii("ç")}, // C cedilla
|
|
|
|
{from_ascii("\\c C"), from_ascii("ç")},
|
|
|
|
{from_ascii("\\v{d}"), from_ascii("ď")}, // d caron
|
|
|
|
{from_ascii("\\v d"), from_ascii("ď")},
|
|
|
|
{from_ascii("\\v{D}"), from_ascii("Ď")}, // D caron
|
|
|
|
{from_ascii("\\v D"), from_ascii("Ď")},
|
|
|
|
{from_ascii("\\`{e}"), from_ascii("é")}, // e acute
|
|
|
|
{from_ascii("\\` e"), from_ascii("é")},
|
|
|
|
{from_ascii("\\`{E}"), from_ascii("É")}, // E acute
|
|
|
|
{from_ascii("\\` E"), from_ascii("É")},
|
|
|
|
{from_ascii("\\u{e}"), from_ascii("ĕ")}, // e breve
|
|
|
|
{from_ascii("\\u e"), from_ascii("ĕ")},
|
|
|
|
{from_ascii("\\u{E}"), from_ascii("Ĕ")}, // E breve
|
|
|
|
{from_ascii("\\u E"), from_ascii("Ĕ")},
|
|
|
|
{from_ascii("\\v{e}"), from_ascii("ě")}, // e caron
|
|
|
|
{from_ascii("\\v e"), from_ascii("ě")},
|
|
|
|
{from_ascii("\\v{E}"), from_ascii("Ě")}, // E caron
|
|
|
|
{from_ascii("\\v E"), from_ascii("Ě")},
|
|
|
|
{from_ascii("\\c{e}"), from_ascii("ȩ")}, // e cedilla
|
|
|
|
{from_ascii("\\c e"), from_ascii("ȩ")},
|
|
|
|
{from_ascii("\\c{E}"), from_ascii("Ȩ")}, // E cedilla
|
|
|
|
{from_ascii("\\c E"), from_ascii("Ȩ")},
|
|
|
|
{from_ascii("\\^{e}"), from_ascii("ê")}, // e circumflex
|
|
|
|
{from_ascii("\\^ e"), from_ascii("ê")},
|
|
|
|
{from_ascii("\\^{E}"), from_ascii("Ê")}, // E circumflex
|
|
|
|
{from_ascii("\\^ E"), from_ascii("Ê")},
|
|
|
|
{from_ascii("\\\"{e}"), from_ascii("ë")}, // e diaeresis
|
|
|
|
{from_ascii("\\\" e"), from_ascii("ë")},
|
|
|
|
{from_ascii("\\\"{E}"), from_ascii("Ë")}, // E diaeresis
|
|
|
|
{from_ascii("\\\" E"), from_ascii("Ë")},
|
|
|
|
// No e double acute.
|
|
|
|
{from_ascii("\\`{e}"), from_ascii("è")}, // e grave
|
|
|
|
{from_ascii("\\` e"), from_ascii("è")},
|
|
|
|
{from_ascii("\\`{E}"), from_ascii("È")}, // E grave
|
|
|
|
{from_ascii("\\` E"), from_ascii("È")},
|
|
|
|
{from_ascii("\\~{e}"), from_ascii("ẽ")}, // e tilde
|
|
|
|
{from_ascii("\\~ e"), from_ascii("ẽ")},
|
|
|
|
{from_ascii("\\~{E}"), from_ascii("Ẽ")}, // E tilde
|
|
|
|
{from_ascii("\\~ E"), from_ascii("Ẽ")},
|
|
|
|
// No e ring.
|
|
|
|
{from_ascii("\\u{g}"), from_ascii("ğ")}, // g breve
|
|
|
|
{from_ascii("\\u g"), from_ascii("ğ")},
|
|
|
|
{from_ascii("\\u{G}"), from_ascii("Ğ")}, // G breve
|
|
|
|
{from_ascii("\\u G"), from_ascii("Ğ")},
|
|
|
|
{from_ascii("\\v{g}"), from_ascii("ǧ")}, // g caron
|
|
|
|
{from_ascii("\\v g"), from_ascii("ǧ")},
|
|
|
|
{from_ascii("\\v{G}"), from_ascii("Ǧ")}, // G caron
|
|
|
|
{from_ascii("\\v G"), from_ascii("Ǧ")},
|
|
|
|
{from_ascii("\\c{g}"), from_ascii("ģ")}, // g cedilla
|
|
|
|
{from_ascii("\\c g"), from_ascii("ģ")},
|
|
|
|
{from_ascii("\\c{G}"), from_ascii("Ģ")}, // G cedilla
|
|
|
|
{from_ascii("\\c G"), from_ascii("Ģ")},
|
|
|
|
{from_ascii("\\i"), from_ascii("ı")}, // i dotless
|
|
|
|
{from_ascii("\\`{i}"), from_ascii("í")}, // i acute
|
|
|
|
{from_ascii("\\` i"), from_ascii("í")},
|
|
|
|
{from_ascii("\\`{I}"), from_ascii("Í")}, // I acute
|
|
|
|
{from_ascii("\\` I"), from_ascii("Í")},
|
|
|
|
{from_ascii("\\u{i}"), from_ascii("ĭ")}, // i breve
|
|
|
|
{from_ascii("\\u i"), from_ascii("ĭ")},
|
|
|
|
{from_ascii("\\u{I}"), from_ascii("Ĭ")}, // I breve
|
|
|
|
{from_ascii("\\u I"), from_ascii("Ĭ")},
|
|
|
|
{from_ascii("\\v{i}"), from_ascii("ǐ")}, // i caron
|
|
|
|
{from_ascii("\\v i"), from_ascii("ǐ")},
|
|
|
|
{from_ascii("\\v{I}"), from_ascii("Ǐ")}, // I caron
|
|
|
|
{from_ascii("\\v I"), from_ascii("Ǐ")},
|
|
|
|
// No i cedilla.
|
|
|
|
{from_ascii("\\^{i}"), from_ascii("î")}, // i circumflex
|
|
|
|
{from_ascii("\\^ i"), from_ascii("î")},
|
|
|
|
{from_ascii("\\^{I}"), from_ascii("Î")}, // I circumflex
|
|
|
|
{from_ascii("\\^ I"), from_ascii("ï")},
|
|
|
|
{from_ascii("\\\"{i}"), from_ascii("ï")}, // i diaeresis
|
|
|
|
{from_ascii("\\\" i"), from_ascii("ë")},
|
|
|
|
{from_ascii("\\\"{I}"), from_ascii("ë")}, // I diaeresis
|
|
|
|
{from_ascii("\\\" I"), from_ascii("Ï")},
|
|
|
|
// No i double acute.
|
|
|
|
{from_ascii("\\`{i}"), from_ascii("ì")}, // i grave
|
|
|
|
{from_ascii("\\` i"), from_ascii("ì")},
|
|
|
|
{from_ascii("\\`{I}"), from_ascii("Ì")}, // I grave
|
|
|
|
{from_ascii("\\` I"), from_ascii("Ì")},
|
|
|
|
{from_ascii("\\~{i}"), from_ascii("ĩ")}, // i tilde
|
|
|
|
{from_ascii("\\~ i"), from_ascii("ĩ")},
|
|
|
|
{from_ascii("\\~{I}"), from_ascii("Ĩ")}, // I tilde
|
|
|
|
{from_ascii("\\~ I"), from_ascii("Ĩ")},
|
|
|
|
// No i ring.
|
|
|
|
{from_ascii("\\j"), from_ascii("ȷ")}, // j dotless
|
|
|
|
{from_ascii("\\v{k}"), from_ascii("Ǩ")}, // k caron
|
|
|
|
{from_ascii("\\v k"), from_ascii("Ǩ")},
|
|
|
|
{from_ascii("\\v{K}"), from_ascii("ǩ")}, // K caron
|
|
|
|
{from_ascii("\\v K"), from_ascii("ǩ")},
|
|
|
|
{from_ascii("\\c{k}"), from_ascii("ķ")}, // k cedilla
|
|
|
|
{from_ascii("\\c k"), from_ascii("ķ")},
|
|
|
|
{from_ascii("\\c{K}"), from_ascii("Ķ")}, // K cedilla
|
|
|
|
{from_ascii("\\c K"), from_ascii("Ķ")},
|
|
|
|
{from_ascii("\\v{l}"), from_ascii("ľ")}, // l caron
|
|
|
|
{from_ascii("\\v l"), from_ascii("ľ")},
|
|
|
|
{from_ascii("\\v{L}"), from_ascii("Ľ")}, // L caron
|
|
|
|
{from_ascii("\\v L"), from_ascii("Ľ")},
|
|
|
|
{from_ascii("\\c{l}"), from_ascii("ļ")}, // l cedilla
|
|
|
|
{from_ascii("\\c l"), from_ascii("ļ")},
|
|
|
|
{from_ascii("\\c{L}"), from_ascii("Ļ")}, // L cedilla
|
|
|
|
{from_ascii("\\c L"), from_ascii("Ļ")},
|
|
|
|
{from_ascii("\\l"), from_ascii("ł")}, // l stroke
|
|
|
|
{from_ascii("\\L"), from_ascii("Ł")}, // L stroke
|
|
|
|
{from_ascii("\\v{n}"), from_ascii("ň")}, // n caron
|
|
|
|
{from_ascii("\\v n"), from_ascii("ň")},
|
|
|
|
{from_ascii("\\v{N}"), from_ascii("Ň")}, // N caron
|
|
|
|
{from_ascii("\\v N"), from_ascii("Ň")},
|
|
|
|
{from_ascii("\\c{n}"), from_ascii("ņ")}, // n cedilla
|
|
|
|
{from_ascii("\\c n"), from_ascii("ņ")},
|
|
|
|
{from_ascii("\\c{N}"), from_ascii("Ņ")}, // N cedilla
|
|
|
|
{from_ascii("\\c N"), from_ascii("Ņ")},
|
|
|
|
{from_ascii("\\~{n}"), from_ascii("ñ")}, // n tilde
|
|
|
|
{from_ascii("\\~ n"), from_ascii("ñ")},
|
|
|
|
{from_ascii("\\~{N}"), from_ascii("Ñ")}, // N tilde
|
|
|
|
{from_ascii("\\~ N"), from_ascii("Ñ")},
|
|
|
|
{from_ascii("\\`{o}"), from_ascii("ó")}, // o acute
|
|
|
|
{from_ascii("\\` o"), from_ascii("ó")},
|
|
|
|
{from_ascii("\\`{O}"), from_ascii("Ó")}, // O acute
|
|
|
|
{from_ascii("\\` O"), from_ascii("Ó")},
|
|
|
|
{from_ascii("\\u{o}"), from_ascii("ŏ")}, // o breve
|
|
|
|
{from_ascii("\\u o"), from_ascii("ŏ")},
|
|
|
|
{from_ascii("\\u{O}"), from_ascii("Ŏ")}, // O breve
|
|
|
|
{from_ascii("\\u O"), from_ascii("Ŏ")},
|
|
|
|
{from_ascii("\\v{o}"), from_ascii("ǒ")}, // o caron
|
|
|
|
{from_ascii("\\v o"), from_ascii("ǒ")},
|
|
|
|
{from_ascii("\\v{O}"), from_ascii("Ǒ")}, // O caron
|
|
|
|
{from_ascii("\\v O"), from_ascii("Ǒ")},
|
|
|
|
// No o cedilla.
|
|
|
|
{from_ascii("\\^{o}"), from_ascii("ô")}, // o circumflex
|
|
|
|
{from_ascii("\\^ o"), from_ascii("ô")},
|
|
|
|
{from_ascii("\\^{O}"), from_ascii("Ô")}, // O circumflex
|
|
|
|
{from_ascii("\\^ O"), from_ascii("Ô")},
|
|
|
|
{from_ascii("\\\"{o}"), from_ascii("ö")}, // o diaeresis
|
|
|
|
{from_ascii("\\\" o"), from_ascii("ö")},
|
|
|
|
{from_ascii("\\\"{O}"), from_ascii("Ö")}, // O diaeresis
|
|
|
|
{from_ascii("\\\" O"), from_ascii("Ö")},
|
|
|
|
{from_ascii("\\H{o}"), from_ascii("ő")}, // o double acute
|
|
|
|
{from_ascii("\\H o"), from_ascii("ő")},
|
|
|
|
{from_ascii("\\H{O}"), from_ascii("Ő")}, // O double acute
|
|
|
|
{from_ascii("\\H O"), from_ascii("Ő")},
|
|
|
|
{from_ascii("\\`{o}"), from_ascii("ò")}, // o grave
|
|
|
|
{from_ascii("\\` o"), from_ascii("ò")},
|
|
|
|
{from_ascii("\\`{O}"), from_ascii("Ò")}, // O grave
|
|
|
|
{from_ascii("\\` O"), from_ascii("Ò")},
|
|
|
|
{from_ascii("\\o"), from_ascii("ø")}, // o stroke
|
|
|
|
{from_ascii("\\O"), from_ascii("Ø")}, // O stroke
|
|
|
|
{from_ascii("\\~{o}"), from_ascii("õ")}, // o tilde
|
|
|
|
{from_ascii("\\~ o"), from_ascii("õ")},
|
|
|
|
{from_ascii("\\~{O}"), from_ascii("Õ")}, // O tilde
|
|
|
|
{from_ascii("\\~ O"), from_ascii("Õ")},
|
|
|
|
// No o ring.
|
|
|
|
{from_ascii("\\oe"), from_ascii("œ")}, // oe ligature
|
|
|
|
{from_ascii("\\OE"), from_ascii("Œ")}, // OE ligature
|
|
|
|
{from_ascii("\\v{r}"), from_ascii("ř")}, // r caron
|
|
|
|
{from_ascii("\\v r"), from_ascii("ř")},
|
|
|
|
{from_ascii("\\v{R}"), from_ascii("Ř")}, // R caron
|
|
|
|
{from_ascii("\\v R"), from_ascii("Ř")},
|
|
|
|
{from_ascii("\\c{r}"), from_ascii("ŗ")}, // r cedilla
|
|
|
|
{from_ascii("\\c r"), from_ascii("ŗ")},
|
|
|
|
{from_ascii("\\c{R}"), from_ascii("Ŗ")}, // R cedilla
|
|
|
|
{from_ascii("\\c R"), from_ascii("Ŗ")},
|
|
|
|
{from_ascii("\\v{s}"), from_ascii("š")}, // s caron
|
|
|
|
{from_ascii("\\v s"), from_ascii("š")},
|
|
|
|
{from_ascii("\\v{S}"), from_ascii("Š")}, // S caron
|
|
|
|
{from_ascii("\\v S"), from_ascii("Š")},
|
|
|
|
{from_ascii("\\c{s}"), from_ascii("ş")}, // s cedilla
|
|
|
|
{from_ascii("\\c s"), from_ascii("ş")},
|
|
|
|
{from_ascii("\\c{S}"), from_ascii("Ş")}, // S cedilla
|
|
|
|
{from_ascii("\\c S"), from_ascii("Ş")},
|
|
|
|
{from_ascii("\\v{t}"), from_ascii("ť")}, // t caron
|
|
|
|
{from_ascii("\\v t"), from_ascii("ť")},
|
|
|
|
{from_ascii("\\v{T}"), from_ascii("Ť")}, // T caron
|
|
|
|
{from_ascii("\\v T"), from_ascii("Ť")},
|
|
|
|
{from_ascii("\\c{t}"), from_ascii("ţ")}, // t cedilla
|
|
|
|
{from_ascii("\\c t"), from_ascii("ţ")},
|
|
|
|
{from_ascii("\\c{T}"), from_ascii("Ţ")}, // T cedilla
|
|
|
|
{from_ascii("\\c T"), from_ascii("Ţ")},
|
|
|
|
{from_ascii("\\`{u}"), from_ascii("ú")}, // u acute
|
|
|
|
{from_ascii("\\` u"), from_ascii("ú")},
|
|
|
|
{from_ascii("\\`{U}"), from_ascii("Ú")}, // U acute
|
|
|
|
{from_ascii("\\` U"), from_ascii("Ú")},
|
|
|
|
{from_ascii("\\u{u}"), from_ascii("ŭ")}, // u breve
|
|
|
|
{from_ascii("\\u u"), from_ascii("ŭ")},
|
|
|
|
{from_ascii("\\u{U}"), from_ascii("Ŭ")}, // U breve
|
|
|
|
{from_ascii("\\u U"), from_ascii("Ŭ")},
|
|
|
|
{from_ascii("\\v{u}"), from_ascii("ǔ")}, // u caron
|
|
|
|
{from_ascii("\\v u"), from_ascii("ǔ")},
|
|
|
|
{from_ascii("\\v{U}"), from_ascii("Ǔ")}, // U caron
|
|
|
|
{from_ascii("\\v U"), from_ascii("Ǔ")},
|
|
|
|
// No u cedilla.
|
|
|
|
{from_ascii("\\^{u}"), from_ascii("û")}, // u circumflex
|
|
|
|
{from_ascii("\\^ u"), from_ascii("û")},
|
|
|
|
{from_ascii("\\^{U}"), from_ascii("Û")}, // U circumflex
|
|
|
|
{from_ascii("\\^ U"), from_ascii("Û")},
|
|
|
|
{from_ascii("\\\"{u}"), from_ascii("ü")}, // u diaeresis
|
|
|
|
{from_ascii("\\\" u"), from_ascii("ü")},
|
|
|
|
{from_ascii("\\\"{U}"), from_ascii("Ü")}, // U diaeresis
|
|
|
|
{from_ascii("\\\" U"), from_ascii("Ü")},
|
|
|
|
{from_ascii("\\H{u}"), from_ascii("ű")}, // u double acute
|
|
|
|
{from_ascii("\\H u"), from_ascii("ű")},
|
|
|
|
{from_ascii("\\H{U}"), from_ascii("Ű")}, // U double acute
|
|
|
|
{from_ascii("\\H U"), from_ascii("Ű")},
|
|
|
|
{from_ascii("\\`{u}"), from_ascii("ù")}, // u grave
|
|
|
|
{from_ascii("\\` u"), from_ascii("ù")},
|
|
|
|
{from_ascii("\\`{U}"), from_ascii("Ù")}, // U grave
|
|
|
|
{from_ascii("\\` U"), from_ascii("Ù")},
|
|
|
|
{from_ascii("\\~{u}"), from_ascii("ũ")}, // u tilde
|
|
|
|
{from_ascii("\\~ u"), from_ascii("ũ")},
|
|
|
|
{from_ascii("\\~{U}"), from_ascii("Ũ")}, // U tilde
|
|
|
|
{from_ascii("\\~ U"), from_ascii("Ũ")},
|
|
|
|
{from_ascii("\\r{u}"), from_ascii("å")}, // u ring
|
|
|
|
{from_ascii("\\r u"), from_ascii("ů")},
|
|
|
|
{from_ascii("\\r{U}"), from_ascii("ů")}, // U ring
|
|
|
|
{from_ascii("\\r U"), from_ascii("Ů")},
|
|
|
|
{from_ascii("\\`{y}"), from_ascii("ý")}, // y acute
|
|
|
|
{from_ascii("\\` y"), from_ascii("ý")},
|
|
|
|
{from_ascii("\\`{Y}"), from_ascii("Ý")}, // Y acute
|
|
|
|
{from_ascii("\\` Y"), from_ascii("Ý")},
|
|
|
|
{from_ascii("\\v{z}"), from_ascii("ž")}, // z caron
|
|
|
|
{from_ascii("\\v z"), from_ascii("ž")},
|
|
|
|
{from_ascii("\\v{Z}"), from_ascii("Ž")}, // Z caron
|
|
|
|
{from_ascii("\\v Z"), from_ascii("Ž")},
|
|
|
|
// No y breve.
|
|
|
|
// No y cedilla.
|
|
|
|
{from_ascii("\\^{y}"), from_ascii("ŷ")}, // y circumflex
|
|
|
|
{from_ascii("\\^ y"), from_ascii("ŷ")},
|
|
|
|
{from_ascii("\\^{Y}"), from_ascii("Ŷ")}, // Y circumflex
|
|
|
|
{from_ascii("\\^ Y"), from_ascii("Ŷ")},
|
|
|
|
{from_ascii("\\\"{y}"), from_ascii("ÿ")}, // y diaeresis
|
|
|
|
{from_ascii("\\\" y"), from_ascii("ÿ")},
|
|
|
|
{from_ascii("\\\"{Y}"), from_ascii("Ÿ")}, // Y diaeresis
|
|
|
|
{from_ascii("\\\" Y"), from_ascii("Ÿ")},
|
|
|
|
// No y double acute.
|
|
|
|
{from_ascii("\\`{y}"), from_ascii("ỳ")}, // y grave
|
|
|
|
{from_ascii("\\` y"), from_ascii("ỳ")},
|
|
|
|
{from_ascii("\\`{Y}"), from_ascii("Ỳ")}, // Y grave
|
|
|
|
{from_ascii("\\` Y"), from_ascii("Ỳ")},
|
|
|
|
{from_ascii("\\~{y}"), from_ascii("ỹ")}, // y tilde
|
|
|
|
{from_ascii("\\~ y"), from_ascii("ỹ")},
|
|
|
|
{from_ascii("\\~{Y}"), from_ascii("Ỹ")}, // Y tilde
|
|
|
|
{from_ascii("\\~ Y"), from_ascii("Ỹ")},
|
|
|
|
// No y ring.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-07-31 15:34:58 +00:00
|
|
|
void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
2020-07-31 15:34:58 +00:00
|
|
|
auto const begin = paragraphs().begin();
|
|
|
|
auto par = begin;
|
|
|
|
auto const end = paragraphs().end();
|
2003-04-02 17:11:38 +00:00
|
|
|
|
2020-08-26 19:19:38 +00:00
|
|
|
odocstringstream os; // No need for XML handling here.
|
2020-07-31 22:02:36 +00:00
|
|
|
|
2020-08-15 22:59:43 +00:00
|
|
|
// Recreate the logic of makeParagraph in output_docbook.cpp, but much simplified: never open <para>
|
2020-07-31 22:02:36 +00:00
|
|
|
// in an ERT, use simple line breaks.
|
2020-08-26 19:19:38 +00:00
|
|
|
// New line after each paragraph of the ERT, save the last one.
|
|
|
|
while (true) { // For each paragraph in the ERT...
|
2021-02-19 16:38:22 +00:00
|
|
|
std::vector<docstring> pars_prepend;
|
|
|
|
std::vector<docstring> pars;
|
|
|
|
std::vector<docstring> pars_append;
|
|
|
|
tie(pars_prepend, pars, pars_append) = par->simpleDocBookOnePar(buffer(), runparams, text().outerFont(distance(begin, par)), 0, false, true);
|
|
|
|
|
|
|
|
for (docstring const & parXML : pars_prepend)
|
|
|
|
xs << XMLStream::ESCAPE_NONE << parXML;
|
2020-08-26 19:19:38 +00:00
|
|
|
auto p = pars.begin();
|
|
|
|
while (true) { // For each line of this ERT paragraph...
|
2021-02-21 12:14:51 +00:00
|
|
|
os << *p;
|
2020-08-26 19:19:38 +00:00
|
|
|
++p;
|
|
|
|
if (p != pars.end())
|
|
|
|
os << "\n";
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2021-02-19 16:38:22 +00:00
|
|
|
for (docstring const & parXML : pars_append)
|
|
|
|
xs << XMLStream::ESCAPE_NONE << parXML;
|
2020-07-31 15:34:58 +00:00
|
|
|
|
2003-04-02 17:11:38 +00:00
|
|
|
++par;
|
2020-07-31 15:34:58 +00:00
|
|
|
if (par != end)
|
2020-08-26 19:19:38 +00:00
|
|
|
os << "\n";
|
|
|
|
else
|
|
|
|
break;
|
2001-10-15 12:21:11 +00:00
|
|
|
}
|
2020-07-31 22:02:36 +00:00
|
|
|
|
2020-11-18 03:34:58 +00:00
|
|
|
// // Implement the special case of \and: split the current item.
|
|
|
|
// if (os.str() == "\\and" || os.str() == "\\and ") {
|
|
|
|
// auto lay = getLayout();
|
|
|
|
// }
|
|
|
|
|
2022-02-07 02:24:11 +00:00
|
|
|
// Try to recognise some commands to have a nicer DocBook output. First step: some commands have a direct mapping
|
|
|
|
// to DocBook, mostly because the mapping is simply text or an XML entity.
|
|
|
|
docstring os_trimmed = trim(os.str());
|
|
|
|
bool output_as_comment = true;
|
|
|
|
|
|
|
|
auto command_raw_translation = raw_latex_encoding_to_unicode_xml.find(os_trimmed);
|
|
|
|
if (command_raw_translation != raw_latex_encoding_to_unicode_xml.end()) {
|
|
|
|
xs << command_raw_translation->second;
|
|
|
|
output_as_comment = false;
|
2021-02-19 21:38:25 +00:00
|
|
|
} else {
|
2022-02-07 02:24:11 +00:00
|
|
|
// If the trimmed ERT ends with {}, try a mapping without it.
|
|
|
|
auto os_braces = os_trimmed.find(from_ascii("{}"));
|
|
|
|
|
|
|
|
if (os_braces != lyx::docstring::npos) {
|
|
|
|
auto key = os_trimmed.substr(0, os_braces);
|
|
|
|
auto command_braces_translation = raw_latex_encoding_to_unicode_xml.find(key);
|
|
|
|
|
|
|
|
if (command_braces_translation != raw_latex_encoding_to_unicode_xml.end()) {
|
|
|
|
xs << command_braces_translation->second;
|
|
|
|
output_as_comment = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, output the ERT as a comment with the appropriate escaping if the command is not recognised.
|
|
|
|
if (output_as_comment) {
|
|
|
|
xs << XMLStream::ESCAPE_NONE << "<!-- ";
|
|
|
|
xs << XMLStream::ESCAPE_COMMENTS << os.str();
|
|
|
|
xs << XMLStream::ESCAPE_NONE << " -->";
|
|
|
|
}
|
2000-03-24 13:24:58 +00:00
|
|
|
}
|
2001-07-24 15:07:09 +00:00
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2001-07-24 15:07:09 +00:00
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2010-11-30 05:02:12 +00:00
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
if (cmd.getArg(0) == "ert") {
|
2015-03-12 14:57:29 +00:00
|
|
|
cur.recordUndoInset(this);
|
2010-11-30 05:02:12 +00:00
|
|
|
setStatus(cur, string2params(to_utf8(cmd.argument())));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//fall-through
|
2001-07-24 15:07:09 +00:00
|
|
|
default:
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
break;
|
2001-07-24 15:07:09 +00:00
|
|
|
}
|
2010-11-30 05:02:12 +00:00
|
|
|
|
2001-07-24 15:07:09 +00:00
|
|
|
}
|
2001-07-24 22:08:49 +00:00
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2004-11-04 19:50:04 +00:00
|
|
|
FuncStatus & status) const
|
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2018-07-10 05:11:59 +00:00
|
|
|
case LFUN_INSET_INSERT:
|
|
|
|
status.setEnabled(false);
|
|
|
|
return true;
|
2009-07-14 18:30:13 +00:00
|
|
|
case LFUN_INSET_MODIFY:
|
2010-11-29 13:30:17 +00:00
|
|
|
if (cmd.getArg(0) == "ert") {
|
|
|
|
status.setEnabled(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//fall through
|
|
|
|
|
2009-07-14 18:30:13 +00:00
|
|
|
default:
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::getStatus(cur, cmd, status);
|
2005-02-03 17:24:40 +00:00
|
|
|
}
|
2004-11-04 19:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 02:40:00 +00:00
|
|
|
|
2009-02-25 22:35:41 +00:00
|
|
|
docstring const InsetERT::buttonLabel(BufferView const & bv) const
|
2001-07-25 19:45:21 +00:00
|
|
|
{
|
2020-12-06 02:25:05 +00:00
|
|
|
// U+1F512 LOCK
|
2020-12-06 02:16:17 +00:00
|
|
|
docstring const locked = tempfile_ ? docstring(1, 0x1F512) : docstring();
|
2020-12-02 20:34:28 +00:00
|
|
|
if (decoration() == InsetDecoration::CLASSIC)
|
2020-12-06 02:16:17 +00:00
|
|
|
return locked + (isOpen(bv) ? _("ERT") : getNewLabel(_("ERT")));
|
|
|
|
return locked + getNewLabel(_("ERT"));
|
2001-07-25 19:45:21 +00:00
|
|
|
}
|
2001-07-27 12:03:36 +00:00
|
|
|
|
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::CollapseStatus InsetERT::string2params(string const & in)
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2003-12-11 15:23:15 +00:00
|
|
|
if (in.empty())
|
2008-04-05 10:34:29 +00:00
|
|
|
return Collapsed;
|
2003-12-10 21:32:05 +00:00
|
|
|
istringstream data(in);
|
2008-04-02 23:06:22 +00:00
|
|
|
Lexer lex;
|
2003-12-10 21:32:05 +00:00
|
|
|
lex.setStream(data);
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.setContext("InsetERT::string2params");
|
|
|
|
lex >> "ert";
|
2003-12-10 21:32:05 +00:00
|
|
|
int s;
|
|
|
|
lex >> s;
|
2008-04-05 10:34:29 +00:00
|
|
|
return static_cast<CollapseStatus>(s);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-26 23:41:35 +00:00
|
|
|
string InsetERT::params2string(CollapseStatus status)
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2003-12-10 21:32:05 +00:00
|
|
|
ostringstream data;
|
2008-03-26 23:41:35 +00:00
|
|
|
data << "ert" << ' ' << status;
|
2003-12-10 21:32:05 +00:00
|
|
|
return data.str();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-09 23:35:40 +00:00
|
|
|
docstring InsetERT::xhtml(XMLStream &, OutputParams const &) const
|
2009-06-12 17:23:17 +00:00
|
|
|
{
|
|
|
|
return docstring();
|
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|