summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2014-01-01 15:20:12 +0000
committerNick White <git@njw.me.uk>2014-01-01 15:20:12 +0000
commit8a580c7a0cae271b5fcf5ab938ad1064323efaf6 (patch)
treef7b655913071241c79ca0d2d4bc3904d64b3c335
parent15ce64e5282d617ca16a98e30ca697b5c31d9dad (diff)
downloadtkread-8a580c7a0cae271b5fcf5ab938ad1064323efaf6.tar.bz2
tkread-8a580c7a0cae271b5fcf5ab938ad1064323efaf6.zip
Add headings to markdown processing
-rwxr-xr-xtkread20
1 files changed, 13 insertions, 7 deletions
diff --git a/tkread b/tkread
index b4f9f2e..ce4bac0 100755
--- a/tkread
+++ b/tkread
@@ -29,9 +29,12 @@ set tagnum 0
set domarkdown 0
set surroundfmt { \
- {"***" "bold italic"} \
- {"**" "bold"} \
- {"*" "italic"} \
+ {"***" "0" "bold italic"} \
+ {"**" "0" "bold"} \
+ {"*" "0" "italic"} \
+ {"===" "0" "italic"} \
+ {"==" "3" "italic"} \
+ {"=" "6" ""} \
}
package require Tk
@@ -55,7 +58,8 @@ proc markup {widget} {
foreach fmt $surroundfmt {
set searchchar [lindex $fmt 0]
- set fmtstring [lindex $fmt 1]
+ set fmtsizemod [lindex $fmt 1]
+ set fmtstring [lindex $fmt 2]
set searchlen [string length $searchchar]
set insection 0
set cur ""
@@ -87,7 +91,8 @@ proc markup {widget} {
$widget tag add tag_$tagnum markon_$x markoff_$x
}
- $widget tag configure tag_$tagnum -font "{$fontfamily} $fontsize $fmtstring"
+ # TODO: change in changeFontSize too if this works
+ $widget tag configure tag_$tagnum -font "{$fontfamily} [expr $fontsize + $fmtsizemod] $fmtstring"
incr tagnum
}
}
@@ -102,8 +107,9 @@ proc changeFontSize {change} {
set fontsize $newsize
.t configure -font "{$fontfamily} $fontsize" -padx [expr $fontsize * 3]
for {set x 0} {$x < $tagnum} {incr x} {
- set fmtstring [lindex [lindex $surroundfmt $x] 1]
- .t tag configure tag_$x -font "{$fontfamily} $fontsize $fmtstring"
+ set fmtstring [lindex [lindex $surroundfmt $x] 2]
+ set fmtsizemod [lindex [lindex $surroundfmt $x] 1]
+ .t tag configure tag_$x -font "{$fontfamily} [expr $fontsize + $fmtsizemod] $fmtstring"
}
}
}