Smart Definition List Creation Clip

This clip will create a definition list in html coding.


  • it will create a blank list with specified number of dt and dd tags in ratio to each other
  • it will create a dl from a highlighted list using either every other, a set ratio or custom set determination of what is a dt and what is a dd
  • it will specify an id or class for the dl for those using css

;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at
;*** donations welcome at
;*** Create a Definition List (DL) in HTML file v2.0
;*** based on the ordered/unordered clip shipped w/ Notetab
;*** posted here:
;*** this version 2.0 involves some code improvements suggested
;*** or inspired by Bob McCallister fortiter at gmail dot com

; Clear variables
^!Set %listID%=^?{Give list an ID (or leave blank)=}; %listClass%=^?{Give list a Class (or leave blank)=}
^!If "^%listID%" = "" skip
^!Set %listID%=" id='^%listID%'"
^!If "^%listClass%" = "" skip
^!Set %listClass%=" class='^%listClass%'"
^!If ^$GetSelSize$ > 0 FormatSelection

;line 22
^!Set %CountDT%=^?{How many Definition Terms (DT):?=1|2|_3|4|5|6|7|8|9}
^!Set %CountDD%=^?{How many Definition Descriptions (DD) per (DT)?=_1|2|3|4|5|6|7|8|9}
^!InsertHtml <dl^%listID%^%listClass%>^P^$StrFill(  <dt></dt>^P^$StrFill(    <dd></dd>^P;^%CountDD%)$;^%CountDT%)$</dl>^P
^!Goto End

;line 29
;Divide selection at paragraph marks to make list
^!SetListDelimiter ^p
^!SetArray %delimited_data%=^$GetSelection$

;figure out if it is just every other one?
^!Set %pattern%="^$StrUpper("^?{Is There a Set Pattern?=_Every Other|Set Ratio|NO}")$"
;^!Set %pattern%=^$StrUpper("^?{Is There a Set Pattern?=_Every Other|Set Ratio|NO]")
^!If "^%pattern%" = "NO" BuildCustom
^!If "^%pattern%" = "SET RATIO" SetRatio
;set to one for every other
^!Set %dd%="1"
^!Goto BuildRatio

^!Set %dd%=^?{How many (DD) Per (DT):?=1|_2|3|4|5|6|7|8|9}
^!Goto BuildRatio

;line 49
;should I test if the ratio works?
;maybe modulus on number if items

^!Set %Count%="1"
^!InsertHtml <dl^%listID%^%listClass%>^P
^!InsertHtml ^$StrFill(" ";2)$<dt>^%delimited_data^%Count%%</dt>^P
^!Inc %Count%
^!Set %CountDD%=^%dd%

^!InsertHtml ^$StrFill(" ";4)$<dd>^%delimited_data^%Count%%</dd>^P
^!Dec %CountDD%
^!Inc %Count%
^!If ^%CountDD% = 0 TestDT ELSE CreateRatioDD

^!If ^%Count% < ^%delimited_data0% CreateRatioDT

^!InsertHtml </dl>^P
;end of Build Ratio
^!Goto End

;line 77
^!Set %Count%="1"
^!InsertHtml <dl^%listID%^%listClass%>^P
^!Set %ThisItem%=^?{Is ^%delimited_data^%Count%% a(DT) or (DD):?=T|_D}
^!If "^%ThisItem%" = "D" CreateCustomDD ELSE CreateCustomDT

^!InsertHtml ^$StrFill(" ";2)$<dt>^%delimited_data^%Count%%</dt>^P
^!Goto TestCustomDT

^!InsertHtml ^$StrFill(" ";4)$<dd>^%delimited_data^%Count%%</dd>^P
^!Goto TestCustomDT

^!Inc %Count%
^!If ^%Count% > ^%delimited_data0% CreateCustomDone
^!Goto CreateCustomSwitch

;line 101
^!InsertHtml </dl>^P
^!Goto Done

;if done say so
^!Info Done
;========= End =========
;line 111

Leave a Reply

Recent Posts