@@ -264,7 +264,7 @@ private void InsertHighLightCodeToCurrentSide(string fileName, HighLightParamete
264
264
position = GetMousePointPosition ( existingPageId ) ;
265
265
}
266
266
267
- var page = InsertHighLightCode ( htmlContent , position , parameters , outline , selectedTextFormated , ( new GenerateHighLight ( ) ) . Config . LineNrReplaceCh , IsSelectedTextInline ( existingPageId ) ) ;
267
+ var page = InsertHighLightCode ( htmlContent , position , parameters , outline , selectedTextFormated , IsSelectedTextInline ( existingPageId ) ) ;
268
268
page . Root . SetAttributeValue ( "ID" , existingPageId ) ;
269
269
270
270
OneNoteApplication . UpdatePageContent ( page . ToString ( ) , DateTime . MinValue ) ;
@@ -416,9 +416,9 @@ private bool IsSelectedTextInline(string pageID)
416
416
/// 產生 XML 插入至 OneNote
417
417
/// Generate XML Insert To OneNote
418
418
/// </summary>
419
- public XDocument InsertHighLightCode ( string htmlContent , string [ ] position , HighLightParameter parameters , XElement outline , bool selectedTextFormated , string lineNrReplacementCh , bool isInline )
419
+ public XDocument InsertHighLightCode ( string htmlContent , string [ ] position , HighLightParameter parameters , XElement outline , bool selectedTextFormated , bool isInline )
420
420
{
421
- XElement children = PrepareFormatedContent ( htmlContent , parameters , lineNrReplacementCh , isInline ) ;
421
+ XElement children = PrepareFormatedContent ( htmlContent , parameters , isInline ) ;
422
422
423
423
bool update = false ;
424
424
if ( outline == null )
@@ -496,8 +496,10 @@ private XElement CreateOutline(string[] position, XElement children)
496
496
return outline ;
497
497
}
498
498
499
- private XElement PrepareFormatedContent ( string htmlContent , HighLightParameter parameters , string lineNrReplacementCh , bool isInline )
499
+ private XElement PrepareFormatedContent ( string htmlContent , HighLightParameter parameters , bool isInline )
500
500
{
501
+ HighLightSection config = ( new GenerateHighLight ( ) ) . Config ;
502
+
501
503
XElement children = new XElement ( ns + "OEChildren" ) ;
502
504
503
505
XElement table = new XElement ( ns + "Table" ) ;
@@ -575,19 +577,26 @@ private XElement PrepareFormatedContent(string htmlContent, HighLightParameter p
575
577
//string nr = string.Format(@"<body style=""font-family:{0}"">", GenerateHighlightContent.GenerateHighLight.Config.OutputArguments["Font"].Value) +
576
578
// itemNr.Replace("'", "'") + "</body>";
577
579
string nr = "" ;
578
- if ( string . IsNullOrEmpty ( lineNrReplacementCh ) )
580
+ if ( string . IsNullOrEmpty ( config . LineNrReplaceCh ) )
579
581
{
580
582
nr = defaultStyle + itemNr . Replace ( "'" , "'" ) + "</pre>" ;
581
583
}
582
584
else
583
585
{
584
- nr = defaultStyle + lineNrReplacementCh . PadLeft ( 5 ) + "</pre>" ;
586
+ nr = defaultStyle + config . LineNrReplaceCh . PadLeft ( 5 ) + "</pre>" ;
585
587
}
586
588
587
- cell1 . Add ( new XElement ( ns + "OEChildren" ,
588
- new XElement ( ns + "OE" ,
589
+ XElement oeElement = new XElement ( ns + "OE" ,
589
590
new XElement ( ns + "T" ,
590
- new XCData ( nr ) ) ) ) ) ;
591
+ new XCData ( nr ) ) ) ;
592
+ if ( ContainsAsianCharacter ( itemLine ) )
593
+ {
594
+ oeElement . Add ( new XAttribute ( "spaceBefore" , config . AsianBeforeSpace ) ) ;
595
+ oeElement . Add ( new XAttribute ( "spaceAfter" , config . AsianAfterSpace ) ) ;
596
+ }
597
+
598
+ cell1 . Add ( new XElement ( ns + "OEChildren" ,
599
+ oeElement ) ) ;
591
600
}
592
601
else
593
602
{
@@ -617,5 +626,10 @@ private XElement PrepareFormatedContent(string htmlContent, HighLightParameter p
617
626
table ) ) ;
618
627
return children ;
619
628
}
629
+
630
+ private bool ContainsAsianCharacter ( string itemLine )
631
+ {
632
+ return itemLine . Any ( c => ( uint ) c >= 0x4E00 && ( uint ) c <= 0x2FA1F ) ;
633
+ }
620
634
}
621
635
}
0 commit comments