summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/elements.h16
-rw-r--r--src/generators/latex/text_g.cpp4
-rw-r--r--src/generators/latex/text_g.h1
-rw-r--r--src/parser/text_p.cpp8
-rw-r--r--src/parser/text_p.h1
5 files changed, 19 insertions, 11 deletions
diff --git a/src/elements.h b/src/elements.h
index 82eb559..5ea4534 100644
--- a/src/elements.h
+++ b/src/elements.h
@@ -23,12 +23,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
typedef std::wstring::iterator iiterator;
typedef std::back_insert_iterator<std::wstring> oiterator;
-struct stext_t;
-struct pstext_t;
-typedef boost::variant<boost::recursive_wrapper<stext_t>,
- boost::recursive_wrapper<pstext_t>,
- std::wstring> text_t;
-
enum stattribute_t {
EMPH,
SEMPH,
@@ -40,9 +34,17 @@ enum stattribute_t {
SUPER,
QUOTE,
SUB,
- LINK
+ LINK,
+ NBSP
};
+struct stext_t;
+struct pstext_t;
+typedef boost::variant<boost::recursive_wrapper<stext_t>,
+ boost::recursive_wrapper<pstext_t>,
+ stattribute_t,
+ std::wstring> text_t;
+
struct stext_t {
stattribute_t attribute;
std::vector<text_t> value;
diff --git a/src/generators/latex/text_g.cpp b/src/generators/latex/text_g.cpp
index 90471ae..e65d80d 100644
--- a/src/generators/latex/text_g.cpp
+++ b/src/generators/latex/text_g.cpp
@@ -19,7 +19,7 @@ latex::text_g::text_g() : text_g::base_type(text_) {
using namespace ka;
using ka::standard_wide::char_;
- text_ = stext_ | pstext_ | ptext_;
+ text_ = stext_ | pstext_ | atom_ | ptext_;
stext_ = &uint_(EMPH) << L"\\emph{" << +text_ << '}'
| &uint_(SEMPH) << L"\\textit{\\emph{" << +text_ << L"}}"
@@ -32,6 +32,8 @@ latex::text_g::text_g() : text_g::base_type(text_) {
| &uint_(QUOTE) << L"``" << +text_ << L"''"
| &uint_(SUB) << L"_{" << +text_ << '}';
+ atom_ = &uint_(NBSP) << '~';
+
pstext_ = &uint_(LINK) << L"\\href{" << ptext_[_1 = ph::at_c<2>(_val)]
<< L"}{" << (+text_)[_1 = ph::at_c<1>(_val)] << '}';
diff --git a/src/generators/latex/text_g.h b/src/generators/latex/text_g.h
index 2d26a4d..e930406 100644
--- a/src/generators/latex/text_g.h
+++ b/src/generators/latex/text_g.h
@@ -28,6 +28,7 @@ struct text_g : ka::grammar<oiterator, text_t()> {
ka::rule<oiterator, text_t()> text_;
ka::rule<oiterator, stext_t()> stext_;
ka::rule<oiterator, pstext_t()> pstext_;
+ ka::rule<oiterator, stattribute_t()> atom_;
ka::rule<oiterator, std::wstring()> ptext_;
text_g();
diff --git a/src/parser/text_p.cpp b/src/parser/text_p.cpp
index 447a556..f833743 100644
--- a/src/parser/text_p.cpp
+++ b/src/parser/text_p.cpp
@@ -20,7 +20,7 @@ text_p::text_p() : text_p::base_type(text_) {
using namespace ph;
using qi::standard_wide::char_;
- text_ = stext_(_r1) | pstext_(_r1) | ptext_(_r1);
+ text_ = stext_(_r1) | pstext_(_r1) | atom_ | ptext_(_r1);
stext_ = lit("***") >> attr(VSEMPH) >> +text_(_r1) >> "***"
| lit("**") >> attr(SEMPH) >> +text_(_r1) >> "**"
@@ -37,7 +37,9 @@ text_p::text_p() : text_p::base_type(text_) {
pstext_ = lit('[') >> attr(LINK) >> +text_(val(L"]")) >> ']' >>
lit('(') >> ptext_(val(L")")) >> ')';
+ atom_ = lit(L"\\ ") >> attr(NBSP);
+
ptext_ = +(echar_ | rchar_(_r1));
- echar_ = lit('\\') >> char_;
- rchar_ = char_ - char_(_r1);
+ echar_ = lit('\\') >> ~char_(' ');
+ rchar_ = ~char_('\\') - char_(_r1);
}
diff --git a/src/parser/text_p.h b/src/parser/text_p.h
index 35fc41f..27f84c0 100644
--- a/src/parser/text_p.h
+++ b/src/parser/text_p.h
@@ -27,6 +27,7 @@ struct text_p : qi::grammar<iiterator, text_t(std::wstring)> {
qi::rule<iiterator, text_t(std::wstring)> text_;
qi::rule<iiterator, stext_t(std::wstring)> stext_;
qi::rule<iiterator, pstext_t(std::wstring)> pstext_;
+ qi::rule<iiterator, stattribute_t()> atom_;
qi::rule<iiterator, std::wstring(std::wstring)> ptext_;
qi::rule<iiterator, wchar_t()> echar_;
qi::rule<iiterator, wchar_t(std::wstring)> rchar_;