From 7db077bd0310ceb42e836f8721a3fddf9144e1b3 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Sat, 13 Feb 2021 11:39:05 +0300 Subject: [PATCH] DSL: Don't convert escaped spaces into non-breakable inside [s] tag --- dsl_details.cc | 15 ++++++++++++++- dsl_details.hh | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dsl_details.cc b/dsl_details.cc index 36484294..67436573 100644 --- a/dsl_details.cc +++ b/dsl_details.cc @@ -174,6 +174,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, root( Node::Tag(), wstring(), wstring() ), stringPos( str.c_str() ), lineStartPos( str.c_str() ), transcriptionCount( 0 ), + mediaCount( 0 ), dictionaryName( dictName ), headword( headword_ ) { @@ -355,6 +356,18 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, ++transcriptionCount; } + // If the tag is [s], we update the mediaCount + if ( name == GD_NATIVE_TO_WS( L"s" ) ) + { + if ( isClosing ) + { + if ( mediaCount ) + --mediaCount; + } + else + ++mediaCount; + } + if ( !isClosing ) { if ( name == GD_NATIVE_TO_WS( L"m" ) || @@ -598,7 +611,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, } } - if ( escaped && ch == L' ' ) + if ( escaped && ch == L' ' && mediaCount == 0 ) ch = 0xA0; // Escaped spaces turn into non-breakable ones in Lingvo textNode->text.push_back( ch ); diff --git a/dsl_details.hh b/dsl_details.hh index 8a632c8d..a4016436 100644 --- a/dsl_details.hh +++ b/dsl_details.hh @@ -93,6 +93,7 @@ private: wchar ch; bool escaped; unsigned transcriptionCount; // >0 = inside a [t] tag + unsigned mediaCount; // >0 = inside a [s] tag void nextChar() THROW_SPEC( eot );