params().html_latex_end.clear();
params().html_math_img_scale = 1.0;
params().output_sync_macro.erase();
- params().setLocalLayout(string(), false);
- params().setLocalLayout(string(), true);
+ params().setLocalLayout(docstring(), false);
+ params().setLocalLayout(docstring(), true);
for (int i = 0; i < 4; ++i) {
params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
else
os << " PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\"";
- docstring preamble = from_utf8(params().preamble);
+ docstring preamble = params().preamble;
if (runparams.flavor != OutputParams::XML ) {
preamble += "<!ENTITY % output.print.png \"IGNORE\">\n";
preamble += "<!ENTITY % output.print.pdf \"IGNORE\">\n";
if (!styles.empty())
os << "\n<!-- Text Class Preamble -->\n" << styles << '\n';
- styles = from_utf8(features.getPreambleSnippets());
+ styles = features.getPreambleSnippets();
if (!styles.empty())
os << "\n<!-- Preamble Snippets -->\n" << styles << '\n';
// we will collect CSS information in a stream, and then output it
// either here, as part of the header, or else in a separate file.
odocstringstream css;
- styles = from_utf8(features.getCSSSnippets());
+ styles = features.getCSSSnippets();
if (!styles.empty())
css << "/* LyX Provided Styles */\n" << styles << '\n';
features.require(feat);
}
} else
- features.addPreambleSnippet(mathpreamble);
+ features.addPreambleSnippet(from_utf8(mathpreamble));
}
}
// with utf8-plain, we do not load packages (see #7766)
features.require(feat);
}
} else
- features.addPreambleSnippet(textpreamble);
+ features.addPreambleSnippet(from_utf8(textpreamble));
}
}
}
// then the preamble
if (!preamble.empty()) {
// remove '\n' from the end of preamble
- string const tmppreamble = rtrim(preamble, "\n");
+ docstring const tmppreamble = rtrim(preamble, "\n");
os << "\\begin_preamble\n"
- << tmppreamble
+ << to_utf8(tmppreamble)
<< "\n\\end_preamble\n";
}
<< convert<string>(maintain_unincluded_children) << '\n';
// local layout information
- string const local_layout = getLocalLayout(false);
+ docstring const local_layout = getLocalLayout(false);
if (!local_layout.empty()) {
// remove '\n' from the end
- string const tmplocal = rtrim(local_layout, "\n");
+ docstring const tmplocal = rtrim(local_layout, "\n");
os << "\\begin_local_layout\n"
- << tmplocal
+ << to_utf8(tmplocal)
<< "\n\\end_local_layout\n";
}
- string const forced_local_layout = getLocalLayout(true);
+ docstring const forced_local_layout = getLocalLayout(true);
if (!forced_local_layout.empty()) {
// remove '\n' from the end
- string const tmplocal = rtrim(forced_local_layout, "\n");
+ docstring const tmplocal = rtrim(forced_local_layout, "\n");
os << "\\begin_forced_local_layout\n"
- << tmplocal
+ << to_utf8(tmplocal)
<< "\n\\end_forced_local_layout\n";
}
|| features.isRequired("varioref")
|| features.isRequired("vietnamese")
|| features.isRequired("japanese"))) {
+ lyxpreamble += features.getBabelPresettings();
// FIXME UNICODE
- lyxpreamble += from_utf8(features.getBabelPresettings());
lyxpreamble += from_utf8(babelCall(language_options.str(),
features.needBabelLangOptions())) + '\n';
- lyxpreamble += from_utf8(features.getBabelPostsettings());
+ lyxpreamble += features.getBabelPostsettings();
}
// The optional packages;
"User specified LaTeX commands.\n";
// Check if the user preamble contains uncodable glyphs
- docstring const u_preamble = from_utf8(preamble);
odocstringstream user_preamble;
docstring uncodable_glyphs;
Encoding const * const enc = features.runparams().encoding;
if (enc) {
- for (size_t n = 0; n < u_preamble.size(); ++n) {
- char_type c = u_preamble[n];
+ for (size_t n = 0; n < preamble.size(); ++n) {
+ char_type c = preamble[n];
if (!enc->encodable(c)) {
docstring const glyph(1, c);
LYXERR0("Uncodable character '"
user_preamble.put(c);
}
} else
- user_preamble << u_preamble;
+ user_preamble << preamble;
// On BUFFER_VIEW|UPDATE, warn user if we found uncodable glyphs
if (!features.runparams().dryrun && !uncodable_glyphs.empty()) {
&& !features.isRequired("varioref")
&& !features.isRequired("vietnamese")
&& !features.isRequired("japanese")) {
+ lyxpreamble += features.getBabelPresettings();
// FIXME UNICODE
- lyxpreamble += from_utf8(features.getBabelPresettings());
lyxpreamble += from_utf8(babelCall(language_options.str(),
features.needBabelLangOptions())) + '\n';
- lyxpreamble += from_utf8(features.getBabelPostsettings());
+ lyxpreamble += features.getBabelPostsettings();
}
if (features.isRequired("bicaption"))
lyxpreamble += "\\usepackage{bicaption}\n";
TextClass::ReturnValues success = TextClass::OK;
if (!forced_local_layout_.empty())
- success = doc_class_->read(forced_local_layout_, TextClass::MODULE);
+ success = doc_class_->read(to_utf8(forced_local_layout_),
+ TextClass::MODULE);
if (!local_layout_.empty() &&
(success == TextClass::OK || success == TextClass::OK_OLDFORMAT))
- success = doc_class_->read(local_layout_, TextClass::MODULE);
+ success = doc_class_->read(to_utf8(local_layout_), TextClass::MODULE);
if (success != TextClass::OK && success != TextClass::OK_OLDFORMAT) {
docstring const msg = _("Error reading internal layout information");
frontend::Alert::warning(_("Read Error"), msg);
}
-std::string BufferParams::getLocalLayout(bool forced) const
+docstring BufferParams::getLocalLayout(bool forced) const
{
if (forced)
- return doc_class_->forcedLayouts();
+ return from_utf8(doc_class_->forcedLayouts());
else
return local_layout_;
}
-void BufferParams::setLocalLayout(string const & layout, bool forced)
+void BufferParams::setLocalLayout(docstring const & layout, bool forced)
{
if (forced)
forced_local_layout_ = layout;
lyxerr << "Error (BufferParams::readPreamble):"
"consistency check failed." << endl;
- preamble = lex.getLongString("\\end_preamble");
+ preamble = lex.getLongString(from_ascii("\\end_preamble"));
}
if (forced)
forced_local_layout_ =
- lex.getLongString("\\end_forced_local_layout");
+ lex.getLongString(from_ascii("\\end_forced_local_layout"));
else
- local_layout_ = lex.getLongString("\\end_local_layout");
+ local_layout_ = lex.getLongString(from_ascii("\\end_local_layout"));
}
/// Clear the removed module list
void clearRemovedModules() { removed_modules_.clear(); }
/// Get the local layouts
- std::string getLocalLayout(bool) const;
+ docstring getLocalLayout(bool forced) const;
/// Set the local layouts
- void setLocalLayout(std::string const &, bool);
+ void setLocalLayout(docstring const & layout, bool forced);
/// returns \c true if the buffer contains a LaTeX document
bool isLatex() const;
///
std::string origin;
///
- std::string preamble;
+ docstring preamble;
///
std::string options;
/// use the class options defined in the layout?
/// the user has chosen not to use
std::list<std::string> removed_modules_;
/// The local layouts without the forced ones
- std::string local_layout_;
+ docstring local_layout_;
/// Forced local layouts only for reading (use getLocalLayout() instead)
- std::string forced_local_layout_;
+ docstring forced_local_layout_;
/// the list of included children (for includeonly)
std::list<std::string> included_children_;
string const & listName, std::string const & listCmd,
string const & refPrefix, std::string const & allowedplacement,
string const & htmlTag, string const & htmlAttrib,
- string const & htmlStyle, bool usesfloat, bool ispredefined,
+ docstring const & htmlStyle, bool usesfloat, bool ispredefined,
bool allowswide, bool allowssideways)
: floattype_(type), placement_(placement), ext_(ext), within_(within),
style_(style), name_(name), listname_(listName), listcommand_(listCmd),
#ifndef FLOATING_H
#define FLOATING_H
+#include "support/strfwd.h"
+
#include <string>
namespace lyx {
-
+
/** This is a "float layout" object. It contains the parameters for how to
* handle the different kinds of floats, default ones and user created ones.
* Objects of this class is stored in a container in FloatList. The different
std::string const & listName, std::string const & listCmd,
std::string const & refPrefix, std::string const & allowedplacement,
std::string const & htmlType, std::string const & htmlClass,
- std::string const & htmlStyle, bool usesfloat, bool isprefined,
+ docstring const & htmlStyle, bool usesfloat, bool isprefined,
bool allowswide, bool allowssideways);
///
std::string const & floattype() const { return floattype_; }
///
bool allowsSideways() const { return allowssideways_; }
/// style information, for preamble
- std::string const & htmlStyle() const { return html_style_; }
+ docstring const & htmlStyle() const { return html_style_; }
/// class, for css, defaults to "float-" + type()
std::string const & htmlAttrib() const;
/// tag type, defaults to "div"
///
mutable std::string defaultcssclass_;
///
- std::string html_style_;
+ docstring html_style_;
};
}
-void LaTeXFeatures::addPreambleSnippet(string const & preamble,
- bool allowdupes)
+void LaTeXFeatures::addPreambleSnippet(docstring const & preamble,
+ bool allowdupes)
{
SnippetList::const_iterator begin = preamble_snippets_.begin();
SnippetList::const_iterator end = preamble_snippets_.end();
void LaTeXFeatures::addCSSSnippet(std::string const & snippet)
{
+ docstring const u_snippet = from_ascii(snippet);
SnippetList::const_iterator begin = css_snippets_.begin();
SnippetList::const_iterator end = css_snippets_.end();
- if (find(begin, end, snippet) == end)
- css_snippets_.push_back(snippet);
+ if (find(begin, end, u_snippet) == end)
+ css_snippets_.push_back(u_snippet);
}
}
-string LaTeXFeatures::getPreambleSnippets() const
+docstring LaTeXFeatures::getPreambleSnippets() const
{
- ostringstream snip;
+ odocstringstream snip;
SnippetList::const_iterator pit = preamble_snippets_.begin();
SnippetList::const_iterator pend = preamble_snippets_.end();
for (; pit != pend; ++pit)
}
-std::string LaTeXFeatures::getCSSSnippets() const
+docstring LaTeXFeatures::getCSSSnippets() const
{
- ostringstream snip;
+ odocstringstream snip;
SnippetList::const_iterator pit = css_snippets_.begin();
SnippetList::const_iterator pend = css_snippets_.end();
for (; pit != pend; ++pit)
if (!preamble_snippets_.empty()) {
macros << '\n';
- macros << from_utf8(getPreambleSnippets());
+ macros << getPreambleSnippets();
}
if (mustProvide("papersize")) {
}
-string const LaTeXFeatures::getBabelPresettings() const
+docstring const LaTeXFeatures::getBabelPresettings() const
{
- ostringstream tmp;
+ odocstringstream tmp;
- LanguageList::const_iterator it = UsedLanguages_.begin();
- LanguageList::const_iterator end = UsedLanguages_.end();
- for (; it != end; ++it)
- if (!(*it)->babel_presettings().empty())
- tmp << (*it)->babel_presettings() << '\n';
+ for (Language const * lang : UsedLanguages_)
+ if (!lang->babel_presettings().empty())
+ tmp << lang->babel_presettings() << '\n';
if (!params_.language->babel_presettings().empty())
tmp << params_.language->babel_presettings() << '\n';
}
-string const LaTeXFeatures::getBabelPostsettings() const
+docstring const LaTeXFeatures::getBabelPostsettings() const
{
- ostringstream tmp;
+ odocstringstream tmp;
- LanguageList::const_iterator it = UsedLanguages_.begin();
- LanguageList::const_iterator end = UsedLanguages_.end();
- for (; it != end; ++it)
- if (!(*it)->babel_postsettings().empty())
- tmp << (*it)->babel_postsettings() << '\n';
+ for (Language const * lang : UsedLanguages_)
+ if (!lang->babel_postsettings().empty())
+ tmp << lang->babel_postsettings() << '\n';
if (!params_.language->babel_postsettings().empty())
tmp << params_.language->babel_postsettings() << '\n';
/// The macros definitions needed by the document
docstring const getMacros() const;
/// Extra preamble code before babel is called
- std::string const getBabelPresettings() const;
+ docstring const getBabelPresettings() const;
/// Extra preamble code after babel is called
- std::string const getBabelPostsettings() const;
+ docstring const getBabelPostsettings() const;
/// Do we need to pass the languages to babel directly?
bool needBabelLangOptions() const;
/// Load AMS packages when appropriate
/// Print requirements to lyxerr
void showStruct() const;
///
- void addPreambleSnippet(std::string const & snippet,
- bool allowdupes = false);
+ void addPreambleSnippet(docstring const & snippet, bool allowdupes = false);
///
- std::string getPreambleSnippets() const;
+ docstring getPreambleSnippets() const;
///
void addCSSSnippet(std::string const &);
///
- std::string getCSSSnippets() const;
+ docstring getCSSSnippets() const;
/// Add a feature name requirements
void require(std::string const & name);
/// Add a set of feature names requirements
///
Features features_;
/// Static preamble bits, from external templates, or anywhere else
- typedef std::list<std::string> SnippetList;
+ typedef std::list<docstring> SnippetList;
///
SnippetList preamble_snippets_;
///
os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale);
if (!preamble_.empty())
- os << preamble_;
+ os << to_utf8(preamble_);
return os.str();
}
lex >> packageoption_;
break;
case LF_PREAMBLE:
- preamble_ = lex.getLongString("EndPreamble");
+ preamble_ = lex.getLongString(from_ascii("EndPreamble"));
break;
case LF_PROVIDES: {
lex.eatLine();
///
docstring requires_;
///
- std::string preamble_;
+ docstring preamble_;
///
bool osfdefault_;
///
break;
case LA_POSTBABELPREAMBLE:
babel_postsettings_ =
- lex.getLongString("EndPostBabelPreamble");
+ lex.getLongString(from_ascii("EndPostBabelPreamble"));
break;
case LA_PREBABELPREAMBLE:
babel_presettings_ =
- lex.getLongString("EndPreBabelPreamble");
+ lex.getLongString(from_ascii("EndPreBabelPreamble"));
break;
case LA_REQUIRES:
lex >> requires_;
/// set variety (needed for rc.spellchecker_alt_lang)
void setVariety(std::string const & v) { variety_ = v; }
/// preamble settings after babel was called
- std::string const babel_postsettings() const { return babel_postsettings_; }
+ docstring babel_postsettings() const { return babel_postsettings_; }
/// preamble settings before babel is called
- std::string const babel_presettings() const { return babel_presettings_; }
+ docstring babel_presettings() const { return babel_presettings_; }
/// This language internally sets a font encoding
bool internalFontEncoding() const { return internal_enc_; }
/// fontenc encoding(s)
///
trivstring variety_;
///
- trivstring babel_postsettings_;
+ trivdocstring babel_postsettings_;
///
- trivstring babel_presettings_;
+ trivdocstring babel_presettings_;
///
trivstring fontenc_;
///
break;
case LT_PREAMBLE:
- preamble_ = from_utf8(lex.getLongString("EndPreamble"));
+ preamble_ = lex.getLongString(from_ascii("EndPreamble"));
break;
case LT_LANGPREAMBLE:
- langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
+ langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
break;
case LT_BABELPREAMBLE:
- babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
+ babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
break;
case LT_LABELTYPE:
break;
case LT_HTMLSTYLE:
- htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
+ htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
break;
case LT_HTMLFORCECSS:
break;
case LT_HTMLPREAMBLE:
- htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble"));
+ htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
break;
case LT_HTMLTITLE:
// I would prefer to give a tag number instead of an explicit token
// here, but it is not possible because Buffer::readDocument uses
// explicit tokens (JMarc)
-string const Lexer::getLongString(string const & endtoken)
+docstring Lexer::getLongString(docstring const & endtoken)
{
- string str;
- string prefix;
+ docstring str;
+ docstring prefix;
bool firstline = true;
while (pimpl_->is) { //< eatLine only reads from is, not from pushTok
if (!eatLine())
// blank line in the file being read
continue;
+ docstring tmpstr = getDocString();
+ docstring const token = trim(tmpstr, " \t");
- string const token = trim(getString(), " \t");
-
- LYXERR(Debug::PARSER, "LongString: `" << getString() << '\'');
+ LYXERR(Debug::PARSER, "LongString: `" << tmpstr << '\'');
// We do a case independent comparison, like searchKeyword does.
- if (compare_ascii_no_case(token, endtoken) == 0)
+ if (compare_no_case(token, endtoken) == 0)
break;
- string tmpstr = getString();
if (firstline) {
- size_t i = tmpstr.find_first_not_of(' ');
+ size_t i = tmpstr.find_first_not_of(char_type(' '));
if (i != string::npos)
prefix = tmpstr.substr(0, i);
firstline = false;
}
if (!pimpl_->is)
- printError("Long string not ended by `" + endtoken + '\'');
+ printError("Long string not ended by `" + to_utf8(endtoken) + '\'');
return str;
}
each following line. This mechanism does not work
perfectly if you use tabs.
*/
- std::string const getLongString(std::string const & endtag);
+ docstring getLongString(docstring const & endtag);
/// Pushes a token list on a stack and replaces it with a new one.
template<int N> void pushTable(LexerKeyword (&table)[N])
latexArgInsets(*owner_, os, rp, layout_->postcommandargs(), "post:");
}
}
- string const snippet = to_utf8(ods.str());
- features.addPreambleSnippet(snippet, true);
+ features.addPreambleSnippet(ods.str(), true);
}
}
break;
case TC_PREAMBLE:
- preamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
+ preamble_ = lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_HTMLPREAMBLE:
- htmlpreamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
+ htmlpreamble_ = lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_HTMLSTYLES:
- htmlstyles_ = from_utf8(lexrc.getLongString("EndStyles"));
+ htmlstyles_ = lexrc.getLongString(from_ascii("EndStyles"));
break;
case TC_HTMLTOCSECTION:
break;
case TC_ADDTOPREAMBLE:
- preamble_ += from_utf8(lexrc.getLongString("EndPreamble"));
+ preamble_ += lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_ADDTOHTMLPREAMBLE:
- htmlpreamble_ += from_utf8(lexrc.getLongString("EndPreamble"));
+ htmlpreamble_ += lexrc.getLongString(from_ascii("EndPreamble"));
break;
case TC_ADDTOHTMLSTYLES:
- htmlstyles_ += from_utf8(lexrc.getLongString("EndStyles"));
+ htmlstyles_ += lexrc.getLongString(from_ascii("EndStyles"));
break;
case TC_PROVIDES: {
string ext;
string htmlattr;
- string htmlstyle;
+ docstring htmlstyle;
string htmltag;
string listname;
string listcommand;
break;
case FT_HTMLSTYLE:
lexrc.next();
- htmlstyle = lexrc.getLongString("EndHTMLStyle");
+ htmlstyle = lexrc.getLongString(from_ascii("EndHTMLStyle"));
break;
case FT_HTMLTAG:
lexrc.next();
void PreambleModule::apply(BufferParams & params)
{
- params.preamble = fromqstr(preambleTE->document()->toPlainText());
+ params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
}
void LocalLayout::apply(BufferParams & params)
{
- string const layout = fromqstr(locallayoutTE->document()->toPlainText());
+ docstring const layout =
+ qstring_to_ucs4(locallayoutTE->document()->toPlainText());
params.setLocalLayout(layout, false);
}
void GuiExternal::updateTemplate()
{
external::Template templ = getTemplate(externalCO->currentIndex());
- externalTB->setPlainText(qt_(templ.helpText));
+ externalTB->setPlainText(toqstr(translateIfPossible(templ.helpText)));
// Ascertain which (if any) transformations the template supports
// and disable tabs and Group Boxes hosting unsupported transforms.
void operator()(value_type const & vt) {
os_ << "PreambleDef " << vt.first << '\n'
- << vt.second
+ << to_utf8(vt.second)
<< "PreambleDefEnd" << endl;
}
os_ << "Template " << et.lyxName << '\n'
<< "\tGuiName " << et.guiName << '\n'
<< "\tHelpText\n"
- << et.helpText
+ << to_utf8(et.helpText)
<< "\tHelpTextEnd\n"
<< "\tInputFormat " << et.inputFormat << '\n'
<< "\tFileFilter " << et.fileRegExp << '\n'
}
-string const
-TemplateManager::getPreambleDefByName(string const & name) const
+docstring TemplateManager::getPreambleDefByName(string const & name) const
{
string const trimmed_name = trim(name);
if (trimmed_name.empty())
- return string();
+ return docstring();
PreambleDefs::const_iterator it = preambledefs.find(trimmed_name);
if (it == preambledefs.end())
- return string();
+ return docstring();
return it->second;
}
case TM_PREAMBLEDEF: {
lex.next();
string const name = lex.getString();
- preambledefs[name] = lex.getLongString(preamble_end_tag);
+ preambledefs[name] = lex.getLongString(from_ascii(preamble_end_tag));
}
break;
break;
case TO_HELPTEXT:
- helpText = lex.getLongString("HelpTextEnd");
+ helpText = lex.getLongString(from_ascii("HelpTextEnd"));
break;
case TO_INPUTFORMAT:
/// What will the button in the GUI say?
std::string guiName;
/// A short help text
- std::string helpText;
+ docstring helpText;
/** The format of the input file. Can be "*", in which case we try and
* ascertain the format from the contents of the file.
*/
/** Map from the LyX name of the preamble definition to the preamble
* definition itself.
*/
- typedef std::map<std::string, std::string> PreambleDefs;
+ typedef std::map<std::string, docstring> PreambleDefs;
static TemplateManager & get();
/** return the preamble definition by LyX name.
* If it isn't found, return an empty std::string.
*/
- std::string const getPreambleDefByName(std::string const & name) const;
+ docstring getPreambleDefByName(std::string const & name) const;
/// noncopyable
TemplateManager(TemplateManager const &) = delete;
void operator=(TemplateManager const &) = delete;
external::TemplateManager & etm = external::TemplateManager::get();
- it = cit->second.preambleNames.begin();
- end = cit->second.preambleNames.end();
- for (; it != end; ++it) {
- string const preamble = etm.getPreambleDefByName(*it);
+ for (string const & name : cit->second.preambleNames) {
+ docstring const preamble = etm.getPreambleDefByName(name);
if (!preamble.empty())
features.addPreambleSnippet(preamble);
}
bgcolor_ = lcolor.getFromLyXName(tmp);
break;
case IL_PREAMBLE:
- preamble_ = from_utf8(lex.getLongString("EndPreamble"));
+ preamble_ = lex.getLongString(from_ascii("EndPreamble"));
break;
case IL_BABELPREAMBLE:
- babelpreamble_ = from_utf8(lex.getLongString("EndBabelPreamble"));
+ babelpreamble_ = lex.getLongString(from_ascii("EndBabelPreamble"));
break;
case IL_LANGPREAMBLE:
- langpreamble_ = from_utf8(lex.getLongString("EndLangPreamble"));
+ langpreamble_ = lex.getLongString(from_ascii("EndLangPreamble"));
break;
case IL_REFPREFIX:
lex >> refprefix_;
lex >> htmlisblock_;
break;
case IL_HTMLSTYLE:
- htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
+ htmlstyle_ = lex.getLongString(from_ascii("EndHTMLStyle"));
break;
case IL_HTMLPREAMBLE:
- htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble"));
+ htmlpreamble_ = lex.getLongString(from_ascii("EndPreamble"));
break;
case IL_REQUIRES: {
lex.eatLine();
docstring const data = getEscapedLabel(features.runparams());
docstring label;
docstring prefix;
- string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
+ docstring const fcmd = getFormattedCmd(data, label, prefix);
if (buffer().params().use_refstyle) {
features.require("refstyle");
if (prefix == "cha")
- features.addPreambleSnippet("\\let\\charef=\\chapref");
+ features.addPreambleSnippet(from_ascii("\\let\\charef=\\chapref"));
else if (!prefix.empty()) {
- string lcmd = "\\AtBeginDocument{\\providecommand" +
- fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}";
+ docstring lcmd = "\\AtBeginDocument{\\providecommand" +
+ fcmd + "[1]{\\ref{" + prefix + ":#1}}}";
features.addPreambleSnippet(lcmd);
}
} else {
// prettyref uses "cha" for chapters, so we provide a kind of
// translation.
if (prefix == "chap")
- features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha");
+ features.addPreambleSnippet(from_ascii("\\let\\pr@chap=\\pr@cha"));
}
} else if (cmd == "eqref" && !buffer().params().use_refstyle)
// with refstyle, we simply output "(\ref{label})"
if (type_ == hullRegexp) {
features.require("color");
- string frcol = lcolor.getLaTeXName(Color_regexpframe);
- string bgcol = "white";
+ docstring frcol = from_utf8(lcolor.getLaTeXName(Color_regexpframe));
+ docstring bgcol = from_ascii("white");
features.addPreambleSnippet(
- string("\\newcommand{\\regexp}[1]{\\fcolorbox{")
- + frcol + string("}{")
- + bgcol + string("}{\\ensuremath{\\mathtt{#1}}}}"));
+ "\\newcommand{\\regexp}[1]{\\fcolorbox{"
+ + frcol + "}{"
+ + bgcol + "}{\\ensuremath{\\mathtt{#1}}}}");
features.addPreambleSnippet(
- string("\\newcommand{\\endregexp}{}"));
+ from_ascii("\\newcommand{\\endregexp}{}"));
}
// Validation is necessary only if not using AMS math.
}
+bool containsOnly(docstring const & s, string const & cset)
+{
+ return s.find_first_not_of(from_ascii(cset)) == string::npos;
+}
+
+
// ale970405+lasgoutt-970425
// rewritten to use new string (Lgb)
string const token(string const & a, char delim, int n)
return a.find(b) != docstring::npos;
}
-///
+/// Returns true if the first argument is made of ascii chars given in the
+/// second argument.
bool containsOnly(std::string const &, std::string const &);
+///
+bool containsOnly(docstring const &, std::string const &);
/** Extracts a token from this string at the nth delim.
Doesn't modify the original string. Similar to strtok.