@@ -25,9 +25,6 @@ var reservedRunes = map[rune]bool{
2525 '\\' : true ,
2626 ')' : true ,
2727 '(' : true ,
28- '╱' : true ,
29- '╲' : true ,
30- '╳' : true ,
3128 ' ' : true ,
3229}
3330
@@ -157,6 +154,8 @@ type Line struct {
157154 //dashed bool
158155 needsNudgingUp bool
159156 needsNudgingDown bool
157+ lonely bool
158+ orientation Orientation
160159
161160 state lineState
162161}
@@ -265,13 +264,13 @@ func (c *Canvas) Lines() []Line {
265264
266265 lines = append (lines , c .linesFromIterator (
267266 diagUp ,
268- []rune {'/' , '╱' , '╳' },
267+ []rune {'/' },
269268 append ([]rune {'o' , '*' , '<' , '>' , '^' , 'v' , '|' }, jointRunes ... ),
270269 )... )
271270
272271 lines = append (lines , c .linesFromIterator (
273272 diagDown ,
274- []rune {'\\' , '╲' , '╳' },
273+ []rune {'\\' },
275274 append ([]rune {'o' , '*' , '<' , '>' , '^' , 'v' , '|' }, jointRunes ... ),
276275 )... )
277276
@@ -499,13 +498,42 @@ func (c *Canvas) isRoundedCorner(i Index) Orientation {
499498 return NONE
500499}
501500
502- // Text returns a slace of all text characters not belonging to part of the diagram.
501+ // Text returns a slice of all text characters not belonging to part of the diagram.
503502// How these characters are identified is rather complicated.
504- func (c * Canvas ) Text () []Text {
505- var text []Text
503+ func (c * Canvas ) Text () []Drawable {
504+ var text []Drawable
505+
506+ newLine := func (i Index , o Orientation ) Line {
507+ stop := i
508+
509+ switch o {
510+ case NE :
511+ stop = i .nEast ()
512+ case SE :
513+ stop = i .sEast ()
514+ }
515+
516+ return Line {
517+ start : i ,
518+ stop : stop ,
519+ lonely : true ,
520+ orientation : o ,
521+ }
522+ }
506523
507524 for i , r := range c .text {
508- text = append (text , Text {start : i , contents : string (r )})
525+ switch r {
526+ // Weird unicode edge cases that markdeep handles. These get
527+ // substituted with lines.
528+ case '╱' :
529+ text = append (text , newLine (i , NE ))
530+ case '╲' :
531+ text = append (text , newLine (i , SE ))
532+ case '╳' :
533+ text = append (text , newLine (i , NE ), newLine (i , SE ))
534+ default :
535+ text = append (text , Text {start : i , contents : string (r )})
536+ }
509537 }
510538
511539 return text
@@ -622,7 +650,6 @@ func (c *Canvas) hasLineAboveOrBelow(i Index) bool {
622650 case '|' :
623651 return c .partOfVerticalLine (i ) || c .partOfRoundedCorner (i )
624652 case '/' , '\\' :
625- // TODO: unicode cases
626653 return c .partOfDiagonalLine (i )
627654 case '-' :
628655 return c .partOfRoundedCorner (i )
0 commit comments