[NTG-context] MKIV: Wrong conversion for \date
Hi Hans, there are a few problems with the keywords for \date in MkIV. \starttext \starttabulate[|l|l|l|] \NC keyword \NC MkII \NC MKIV \NC\NR \NC day \NC 4\NC \currentdate[day] \NC\NR \NC day+ \NC 4\NC \currentdate[day+] \NC\NR \NC month\NC April\NC \currentdate[month]\NC\NR \NC year \NC 2011 \NC \currentdate[year] \NC\NR \NC d\NC 4\NC \currentdate[d]\NC\NR \NC d+ \NC 4\NC \currentdate[d+] \NC\NR \NC m\NC April\NC \currentdate[m]\NC\NR \NC j\NC 2011 \NC \currentdate[j]\NC\NR \NC y\NC 2011 \NC \currentdate[y]\NC\NR \NC w\NC Monday \NC \currentdate[w]\NC\NR \NC dd \NC 04 \NC \currentdate[dd] \NC\NR \NC dd+ \NC 4\NC \currentdate[dd+] \NC\NR \NC mm \NC 04 \NC \currentdate[mm] \NC\NR \NC jj \NC 11 \NC \currentdate[jj] \NC\NR \NC yy \NC 11 \NC \currentdate[yy] \NC\NR \NC weekday \NC Monday \NC \currentdate[weekday] \NC\NR \NC referral \NC 20110404 \NC \currentdate[referral] \NC\NR \stoptabulate \stoptext What i miss is also a way to get the month with a single digit, e.g. \currentdate[day,.,month,.,year] print “4.April.2011” but i want “4.4.2011”. Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] sorted data in mkiv
I am writing a booklet for use by junior doctors at the hospital where I work. It will contain random bits of data that is available from various online sources such as phone numbers, dosages of exotic drugs, referral routes and assorted things better written down than remembered. Much of it is in tabular form, and I have so far used natural tables. It is intended to be extremely compact so I make many adjustments to save space, such as using multiple columns where appropriate. Some of the things listed would benefit from being sorted such as phone numbers, but I would still like it to be presented in a table (with the added complication that the table will have two columns of names}. Using pseudocode I would like it to work like this: \phone{person c}{54321, 12345} \phone{clinic a}{12345, 54321} \phone{clinic c}{54321, 12345} \phone{person b}{12345} \phone{clinic b}{12345} \phone{person a}{12345} This should automatically be converted to \bTABLE \bTR\bTD person a\eTD\bTD 12345\eTD\bTD clinic a\eTD\bTD 12345, 54321\eTD\eTR \bTR\bTD person b\eTD\bTD 12345\eTD\bTD clinic b\eTD\bTD 12345\eTD\eTR \bTR\bTD person c\eTD\bTD 54321, 12345\eTD\bTD clinic c\eTD\bTD 54321, 12345\eTD\eTR \eTABLE presumably using something like 1. name and number added to a register 2. register is sorted on first field 3. t = total number of entries in register 4. l = number of lines in table, calculated as l=t\2 + t mod 2 3. create a table with l lines where each line has \bTR\bTD name(i) \eTD\bTD phone(i)\eTD\bTD name(i+l)\eTD\bTD phone(i+l)\eTR It would not surprise me if this is implemented somewhere in ConTeXt but I have been unable to find it. I would be very happy to see a solution using lua, but I lack the knowledge to implement it myself. Regards, Johan -- Johan Sandblom, MD PhD m +46735521477 Sweden What is wanted is not the will to believe, but the will to find out, which is the exact opposite - Bertrand Russell ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] ConTeXt-ifying Kile
# \processaction # \processallactionsinset \processblocks[names][names] # \processcommacommand # \processcommalist # \processfirstactioninset \processpage[names][yes|no] # \processXMLbuffer # \processXMLelement # \processXMLfile # \processXMLfilegrouped # \product \program[name] # \project # \protect \publication[reference] \quotation{text} \quote{text} \ran{text} # \readfile \ref[t|p|r|s|e][reference] \reference[reference]{text} \referral[options] \referraldate \register[text]{register+register+register} \reservefloat[options][text][references]{text} \reset[names] # \resetlayer \resetmarking[name] \rightaligned{text} \Romannumerals{text} \romannumerals{text} \rotate[settings]{text} # \saveXMLasdata # \saveXMLdata # \saveXMLelement # \sbox \scale[options]{text} # \scratchbox # \scratchcounter # \scratchdimen # \scratchskip \screen \section[references]{text} \seeregister[text]{text}{text+text+text} \selectblocks[names][names][critererium] \selectpaper[options] \selectversion # \setcollector # \setevalue # \setevariables # \setflag # \setfontstrut # \setgvalue # \setgvariables # \setlayer # \setlayerframed # \setlocalhsize # \setstrut \settextvariable[name]{text} \setupalign[options] \setuparranging[options] # \setupattachments \setupbackground[options] \setupbackgrounds[position][position][state][settings] \setupblackrules[options] \setupblank[options] \setupblock[names][options] \setupbodyfont[options] \setupbodyfontenvironment[settings][settings] \setupbottom[settings][settings] \setupbottomtexts[text|margin|edge][text|section|date|mark|pagenumber][text|section|date|mark|pagenumber] \setupbuffer[name][options] \setupbuttons[state][settings] \setupcapitals[title=yes|no][sc=yes|no] \setupcaption[name][settings] \setupcaptions[options] \setupclipping[options] \setupcolor[name] \setupcolors[options] \setupcolumns[options] \setupcombinations[options] \setupcombinedlist[name][levels and options] \setupcomment[options] \setupdescriptions[names][options] # \setupencoding \setupenumerations[names][settings] \setupexternalfigures[options] \setupfield[name][label|horizontal|vertical|frame][settings] \setupfields[names][reset|label|horizontal|vertical|frame][options][settings][settings] \setupfillinlines[options] \setupfillinrules[options] \setupfloat[name][options] \setupfloats[options] \setupfloatsplitting[options] # \setupFLOWcharts # \setupFLOWlines # \setupFLOWshapes # \setupfontsynonym \setupfooter[text|margin|edge][options] \setupfootertexts[text|margin|edge][text|section|date|mark|pagenumber][text|section|date|mark|pagenumber] \setupfootnotedefinition[settings] \setupfootnotes[options] \setupforms[method=HTML|FDF] \setupformulae[options] \setupframed[options] \setupframedtexts[options] \setuphead[sections][options] \setupheader[text|margin|edge][options] \setupheadertexts[text|margin|edge][text|section|date|mark|pagenumber][text|section|date|mark|pagenumber] \setupheadnumber[section][number|+number|-number] \setupheads[options] \setupheadtext[language code][name=text] \setuphyphenmark[sign=-|--|---|( )|=|/] \setupindentations[names][options] \setupindenting[none|small|medium|big|next|first|normal|odd|even|dimension] \setupinmargin[left|right|number][options] \setupinteraction[options] \setupinteractionbar[options] \setupinteractionscreen[options] \setupinterlinespace[reset|small|medium|auto|big|on|off][options] \setupitemgroup[name][number|each][options][options] \setupitems[options] \setuplabeltext[language code][name=text] \setuplanguage[language code][settings] # \setuplayer \setuplayout[options] \setuplegend[options] \setuplinenumbering[options] \setuplines[options] \setuplinewidth[dimension] \setuplist[names][options] \setupmakeup[name][options] \setupmarginblocks[options] \setupmarginrules[level=number|rulethickness=dimension] \setupmarking[name][options] \setupnarrower[options] \setupnumbering[options] \setupoppositeplacing[options] \setupoutput[names] \setuppagenumber[number][state=start|stop|keep] \setuppagenumbering[options] \setuppagetransitions[options] \setuppalet[name] \setuppaper[options] \setuppapersize[typesetting papersize][printing papersize] \setupparagraphnumbering[options] \setupparagraphs[name][number|each][options] \setuppositioning[options] \setupprofiles[options] \setupprograms[directory=text] \setuppublications[options] \setupquote[options] \setupreferencelist[names][options] \setupreferencing[options] \setupregister[singular][name][options] \setuprotate[options] \setuprule[name][options] # \setups \setupscreens[options] \setupsection[name][name][options] \setupsectionblock[name][options] \setupsorting[name][options] \setupspacing[broad|packed] \setupstrut[yes|no|cap|text] \setupsubpagenumber[options] \setupsymbolset[name] \setupsynchronization[state=start|stop] \setupsynchronizationbar[options] \setupsynonyms[name][options] \setupsystem[options] \setuptab[options] # \setupTABLE \setuptables[options] \setuptabulate[name][options] \setuptext[text|margin|edge][options
Re: [NTG-context] Doc to ConTeXt [was Re: HTML to ConTeXt]
Hi Andrea, I face a similar issue while organizing large-scale documents prepared by members of my group (many folks are not conversant with TeX here and write documents with WORD). My solution was to take their input through a wiki and convert the HTML to context markup using filters written with ruby (also see http://wiki.contextgarden.net/HTML_and_ConTeXt). Converting HTML syntax to ConTeXt syntax is very do-able. If it is of any use, I attach the ruby filters I use for my purpose. BTW, I use a ruby library called hpricot to ease some of these conversions. saji ... def scrape_the_page(pagePath,oFile,hFile) items_to_remove = [ #menus,#menus notice div.markedup, div.navigation, head, #table of contents hr ] doc=Hpricot(open(pagePath)) # this may not be applicable to your case # this removes some unnecessary markup from the Wiki pages @article = (doc/#container).each do |content| #remove unnecessary content and edit links items_to_remove.each { |x| (content/x).remove } end # Write HTML content to file hFile.write @article.inner_html # How to replace various syntactic elements using Hpricot # replace p/b element with \bf (@article/p/*/b).each do |pb| pb.swap({\\bf #{pb.inner_html}}) end # replace p/b element with \bf (@article/p/b).each do |pb| pb.swap({\\bf #{pb.inner_html}}) end # replace strong element with \bf (@article/strong).each do |ps| ps.swap({\\bf #{ps.inner_html}}) end # replace h1 element with section (@article/h1).each do |h1| h1.swap(\\section{#{h1.inner_html}}) end # replace h2 element with subsection (@article/h2).each do |h2| h2.swap(\\subsection{#{h2.inner_html}}) end # replace h3 element with subsection (@article/h3).each do |h3| h3.swap(\\subsubsection{#{h3.inner_html}}) end # replace h4 element with subsection (@article/h4).each do |h4| h4.swap(\\subsubsubsection{#{h4.inner_html}}) end # replace h5 element with subsection (@article/h5).each do |h5| h5.swap(\\subsubsubsubsection{#{h5.inner_html}}) end # replace precode by equivalent command in context (@article/pre).each do |pre| pre.swap(\\startcode \n #{pre.at(code).inner_html} \n \\stopcode) end # when we encounter a reference to a figure inside the html # we replace it with a ConTeXt reference (@article/a).each do |a| a.swap(\\in[#{a.inner_html}]) end # remove 'alt' attribute inside img element # replace pimg by equivalent command in context (@article/p/img).each do |img| img_attrs=img.attributes['alt'].split(,) # separate the file name from the extension # have to take of file names that have a . embedded in them img_src=img.attributes['src'].reverse.sub(/\w+\./,).reverse # puts img_src # see if position of figure is indicated img_pos=force img_attrs.each do |arr| img_pos=arr.gsub(position=,) if arr.match(position=) end img_attrs.delete(position=#{img_pos}) unless img_pos==force # see if the array img_attrs contains an referral key word if img_attrs.first.match(/\w+[=]\w+/) img_id= else img_id=img_attrs.first img_attrs.delete_at(0) end if img_pos==force if img.attributes['title'] img.swap( \\placefigure\n [#{img_pos}][#{img_id}] \n {#{img.attributes['title']}} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) else img.swap( \\placefigure\n [#{img_pos}] \n {none} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} ) end else if img.attributes['title'] img.swap( \\placefigure\n [#{img_pos}][#{img_id}] \n {#{img.attributes['title']}} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) else img.swap( \\placefigure\n [#{img_pos}] \n {none} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) end end end # end of converting inside (@article/p/img) # why not search for table and if we find caption, keep it ; if not add an empty # Styling options: Here I catch the div element called Col2 and # format the tex document in 2 columns # Tables : placing them # replace pimg by equivalent command in context (@article/table).each do |tab| if tab.at(caption) tab.swap( \\placetable[split]{#{tab.at(caption).inner_html}}\n {\\bTABLE \n #{tab.inner_html} \\eTABLE} ) else tab.swap( \\placetable[split]{}\n {\\bTABLE \n #{tab.inner_html} \\eTABLE} \n ) end end # Tables: remove the caption (@article/caption).each do |cap| cap.swap(\n) end # Now we transfer the syntactically altered html to a string Object # and manipulate that object further [EMAIL PROTECTED] # remove empty space in the beginning newdoc.gsub!(/^\s+/,) # remove all elements we don't need. newdoc.gsub!(/^div.*/,) newdoc.gsub!(/^\/div.*/,) newdoc.gsub!(/^form.*/,) newdoc.gsub!(/^\/form.*/,) newdoc.gsub!(/p/,\n) newdoc.gsub!(/\/p/,\n
[NTG-context] Html to Context using Wiki + hpricot
# we replace it with a ConTeXt reference (@article/a).each do |a| a.swap(\\in[#{a.inner_html}]) end # remove 'alt' attribute inside img element # replace pimg by equivalent command in context (@article/p/img).each do |img| img_attrs=img.attributes['alt'].split(,) # separate the file name from the extension # have to take of file names that have a . embedded in them img_src=img.attributes['src'].reverse.sub(/\w+\./,).reverse # puts img_src # see if position of figure is indicated img_pos=force img_attrs.each do |arr| img_pos=arr.gsub(position=,) if arr.match(position=) end img_attrs.delete(position=#{img_pos}) unless img_pos==force # see if the array img_attrs contains an referral key word if img_attrs.first.match(/\w+[=]\w+/) img_id= else img_id=img_attrs.first img_attrs.delete_at(0) end if img_pos==force if img.attributes['title'] img.swap( \\placefigure\n [#{img_pos}][#{img_id}] \n {#{img.attributes['title']}} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) else img.swap( \\placefigure\n [#{img_pos}] \n {none} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} ) end else if img.attributes['title'] img.swap( \\placefigure\n [#{img_pos}][#{img_id}] \n {#{img.attributes['title']}} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) else img.swap( \\placefigure\n [#{img_pos}] \n {none} \n {\\externalfigure[#{img_src}][#{img_attrs.join(,)}]} \n ) end end end # end of converting inside (@article/p/img) # why not search for table and if we find caption, keep it ; if not add an empty # Styling options: Here I catch the div element called Col2 and # format the tex document in 2 columns # Tables : placing them # replace pimg by equivalent command in context (@article/table).each do |tab| if tab.at(caption) tab.swap( \\placetable[split]{#{tab.at(caption).inner_html}}\n {\\bTABLE \n #{tab.inner_html} \\eTABLE} ) else tab.swap( \\placetable[split]{}\n {\\bTABLE \n #{tab.inner_html} \\eTABLE} \n ) end end # Tables: remove the caption (@article/caption).each do |cap| cap.swap(\n) end # Now we transfer the syntactically altered html to a string Object # and manipulate that object further [EMAIL PROTECTED] # remove empty space in the beginning newdoc.gsub!(/^\s+/,) # remove all elements we don't need. newdoc.gsub!(/^div.*/,) newdoc.gsub!(/^\/div.*/,) newdoc.gsub!(/^form.*/,) newdoc.gsub!(/^\/form.*/,) newdoc.gsub!(/p/,\n) newdoc.gsub!(/\/p/,\n) newdoc.gsub!(/\u/,) newdoc.gsub!(/\/u/,) newdoc.gsub!(/ul/,\\startitemize[1]) newdoc.gsub!(/\/ul/,\\stopitemize) newdoc.gsub!(/ol/,\\startitemize[n]) newdoc.gsub!(/\/ol/,\\stopitemize) newdoc.gsub!(/li/,\\item ) newdoc.gsub!(/\/li/,\n) newdoc.gsub!(_,\\_) newdoc.gsub!(/table/,\\bTABLE \n) newdoc.gsub!(/\/table/,\\eTABLE \n) newdoc.gsub!(/tr/,\\bTR ) newdoc.gsub!(/\/tr/,\\eTR ) newdoc.gsub!(/td/,\\bTD ) newdoc.gsub!(/\/td/,\\eTD ) newdoc.gsub!(/th/,\\bTH ) newdoc.gsub!(/\/th/,\\eTH ) newdoc.gsub!(/center/,) newdoc.gsub!(/\/center/,) newdoc.gsub!(/em/,{\\em ) newdoc.gsub!(/\/em/,}) newdoc.gsub!(^,) newdoc.gsub!(\%,\\%) newdoc.gsub!(amp;,) newdoc.gsub!(,'\\\') newdoc.gsub!($,'\\$') newdoc.gsub!(/tbody/,\\bTABLEbody \n) newdoc.gsub!(/\/tbody/,\\eTABLEbody \n) # Context does not mind _ in figures and does not recognize \_, # so i have to catch these and replace \_ with _ # First catch filter=/\/AnnRep07\/Figures\/(\w+\/)*(\w+\\_)*/ if newdoc[filter] newdoc.gsub!(filter) { |fString| fString.gsub(\\_,_) } end # Second catch filter2=/\/AnnRep07\/Figures\/(\w+\/)*\w+[-.]\w+\\_\w+/ if newdoc[filter2] newdoc.gsub!(filter2) { |fString| fString.gsub(\\_,_) } end # Third catch; remove \_ inside [] filter3=/\[\w+\\_\w+\]/ if newdoc[filter3] newdoc.gsub!(filter3) { |fString| puts fString fString.gsub(\\_,_) } end # remove the comment tag, which we used to embed context commands newdoc.gsub!(!--,) newdoc.gsub!(--,) # add full path to the images newdoc.gsub!(\/AnnRep07\/Figures\/,~\/AnnRep07\/Figures\/) newdoc.gsub!(/\w+\s*\//,) #puts newdoc # open file for output #outfil=#{oFile}.tex #`rm #{outfil}` #fil=File.new(outfil,a) #puts Writing #{oFile} oFile.write newdoc end # imgProps={} # img_attrs.each do |arr| # imgProps['width']=arr.gsub(width=,) if arr.match(width=) # imgProps['position']=arr.gsub(position=,) if arr.match(position=) # end % End of scrape_page.rb -- Saji N. Hameed APEC Climate Center +82 51 668 7470 National Pension Corporation Busan Building 12F Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 [EMAIL PROTECTED] KOREA
[NTG-context] Version Numbers in Download File Names
Hi! Pardon me for requesting more support from pragma-ade prior to ever using the mailing list for general support questions. Maybe I should post this one directly to Hans but others might be interested in this issue as well. Despite my little but growing knowledge of Context I am currently evaluating its suitability for document building in our company (our workflow is currently Latex-based). A prime aspect of our company's work is to follow well-defined processes, and as part of that, we have to be able to refer to specific versions of applications that are used in the development of our projects. When used, this would apply to Context as well. Obviously, downloading from pragma-ade gives version numbers only on the entry pages like http://www.pragma-ade.nl/download-1.htm next to the links to the files, but the package files themselves like http://www.pragma-ade.nl/context/current/cont-tmf.zip don't have versioned names (not mentioning that Context and its modules actually _do_ report version numbers as dates upon use). Is there a strong motivation against having versioned package file names, possibly with some months/years of history? Has this support feature ever been considered by pragma-ade or asked for by their (non-)paying customers? Or is this archive available but I am unable to find it? ;) Just an example: Instead of http://www.pragma-ade.nl/context/current/cont-tmf.zip use a browseable directory like http://www.pragma-ade.nl/context/archive/ containint files like http://www.pragma-ade.nl/context/archive/cont-tmf-20060518.zip http://www.pragma-ade.nl/context/archive/cont-tmf-20060601.zip http://www.pragma-ade.nl/context/archive/cont-tmf-20060629.zip and possibly set /context/current/cont-tmf.zip as an internal file system link to the latest file in /context/archive/ for those interested only in the latest version. The proposed method could be applied to all other download files as well. That way and as long as the archive files are available, a precise version of Context could be fetched from pragma-ade's server without maintaining a local versioned archive of cont.tmf.zip etc. Referral to a specific version of Context would be a lot easier, and documenting the tools used for a project would be a lot simpler. A common understanding of a Context version, reflected in its package file name, would reduce the effort of those responsible for local version control and install package maintenance. Thanks, - Matthias ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Version Numbers in Download File Names
Matthias Wächter wrote: Is there a strong motivation against having versioned package file names, possibly with some months/years of history? Has this support feature ever been considered by pragma-ade or asked for by their (non-)paying customers? Or is this archive available but I am unable to find it? ;) here we seldom use specific version; we do have project specific minimal trees because different projects demand different commercial fonts, and there are situations where experimental features are used that are not yet stable. on a local ox one can do things like: /distributions/context-20050518/ which we initialize with setuptex (see minimal distribution) and or by using texmfstart --tree (see manual) taco has a complete archive Just an example: Instead of http://www.pragma-ade.nl/context/current/cont-tmf.zip use a browseable directory like http://www.pragma-ade.nl/context/archive/ containint files like http://www.pragma-ade.nl/context/archive/cont-tmf-20060518.zip http://www.pragma-ade.nl/context/archive/cont-tmf-20060601.zip http://www.pragma-ade.nl/context/archive/cont-tmf-20060629.zip and possibly set /context/current/cont-tmf.zip as an internal file system link to the latest file in /context/archive/ for those interested only in the latest version. The proposed method could be applied to all other download files as well. although windows (on which we develop context) provides different link systems i seldom use them; also, the server has just a copy of my local stuff and not more; That way and as long as the archive files are available, a precise version of Context could be fetched from pragma-ade's server without maintaining a local versioned archive of cont.tmf.zip etc. Referral to a specific version of Context would be a lot easier, and documenting the tools used for a project would be a lot simpler. A common understanding of a Context version, the toolkit is upward compatible as much as possible (at least in functional terms); the most sensitive parts of tex setups are the fonts (but that will simplify in the near future with new versions of pdftex and open type) reflected in its package file name, would reduce the effort of those responsible for local version control and install package maintenance. taco maintains a svn repository on the gforce server at superlec ; in principle one can rebuild older versions from there however, the best way to archive is to use the minimal distributions (or your own ones built of them) because context files are just part of the story: fonts, patterne etc also play a role; in a year or so, you we hope to be able to run dirtectly from zip files, which makes live even more simple Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context