[total novice again ;-)]
Hi,
Ok, I’ve figured some of this pattern-matching out (yes, I’m really a
total novice at programming). Consider the following:
====================================
@data.gsub!(/<(text:span
text:style-name=“T10”)>(.?)</text:span>/mois) do
‘{’ + '\bf ’ + $2 + ‘}’
end
@data.gsub!(/<(text:span
text:style-name=“Style2”)>(.?)</text:span>/mois) do
‘{’ + ‘\it ’ + $2 + ‘}’
end
@data.gsub!(/text:span.*?text:style-name=([\’\"])(.*?)\1(.*?)</text:span>/)
do
tag, text = $2, $3
if inline[tag] then
(inline[tag][0]||’’) + clean_display(text) +
(inline[tag][1]||’’)
else
clean_display(text)
end
end
How can I condense this? I want something that says, eg.
If style-name equals “T10” or “Style2” or “Style3” then do \bf or \it
or \sl respectively. Otherwise, do clean_display (defined elsewhere).
The first line should look like this
==================
@data.gsub!(/<(text:span
text:style-name=(“T10”|“Style2”|“Style3”))>(.*?)</text:span>/mois) do
but how do I modify the
==================
‘{’ + '\bf ’ + $2 + ‘}’
line?
Best
Idris