How to split the query column value into two line inside of anchor tag using coldfusion? - anchor

I've cfquery loop, then I've displayed the one query column value(Text) into anchor tag.
For Example
<cfloop query="testQuery">
#testQuery.Title#
</cfloop>
Assume that testQuery.Title variable is return "Defines an explanation/pronunciation of characters (for East Asian typography)"
But I need to break the sentence for Example
"Defines an explanation/pronunciation of
characters (for East Asian typography)"

Just put the link into a wrapper and set some width.
<cfloop query="testQuery">
<div style="width:200px !important">#testQuery.Title#</div>
</cfloop>
Let me know if you have any more problem/it is not working.

Related

How can I remove easly Shortcodes inside a Google Sheet?

I am tryng to get rid of shortcodes inside a Google Sheet column. I have many items such as [spacer type="1" height="20"][spacer] or [FinalTilesGallery id="37"] I just would like to cancel them. Is there any simple way to do it?
Thanks !
For in-place replacement, the quick option would be to use the Find and Replace dialog (Ctrl + H) with Search Using Regular Expressions turned on, which is more powerful than your standard Find and Replace.
Find: \[.*?\] - Match anything within an open-bracket up to the very next close-bracket. This should work assuming you have no nested brackets, e.g. [[no][no]].
If you do have nested brackets, you'll have to change this to \[[^\[\]]*\]. And continue to Replace All until all the codes are gone.
Replace: Nothing.
Replace All. If you don't want to affect other sheets that may be in your document, make sure you select the right range to work with, too.
This just erases everything within the brackets.
If you want to erase any redundant spaces left by this, simply Find and Replace again (with Regular Expressions) on + (space and plus), which will match 1 or more spaces and replace with (single space).
E.g.:
string [] [] string2 -> string string2 after the shortcode replacement.
After replacing spaces, it will become string string2.
Let's say your original strings are in the range A2:A. Place the following into B2 of an otherwise completely empty Column B (or the second cell of any other empty column):
=ArrayFormula(IF(A2:A="",,TRIM(REGEXREPLACE(A2:A,"\[[^\[\]]+\]",""))))
I can't see your data, so I don't know what kind of information is between these shortcodes. If you find that this leaves you with concatenated pieces of data where there should be spaces between them, replace the above with this version:
=ArrayFormula(IF(A2:A="",,TRIM(REGEXREPLACE(SUBSTITUTE(SUBSTITUTE(A2:A,"["," ["),"]","] "),"\[[^\[\]]+\]",""))))
I can't teach regular expression language here. But I will note that, since square brackets have specific meaning within regex, your literal square brackets must be indicated with the escape character: the backslash.
Here is the regex expression alone:
\[[^\[\]]+\]
The opening \[ and the closing \], then, reference your actual opening and closing bracket sets. If we remove those, we have this left:
[^\[\]]+
Again, you see the escaped opening and closing square brackets, which I'll replace with the word these:
[^these]+
What remains there are opening and closing brackets with regex meaning, i.e., "anything in this group." And the circumflex symbol ^ as the first character within this set of square brackets means "anything except." The + symbol means "in any string length of one or more characters."
So that whole regex expression then reads: "A literal open square bracket, followed by one or more characters that are anything except square brackets, ending with a literal closing square bracket."
And we are REGEXREPLACE-ing any instance of that with "" (i.e., nothing).

Lua pattern -- how can I get this to work?

I have a text file to process, with some example content as follows:
[FCT-FCTVALUEXXXX-IA]
Name=value
Label = value
Zero or more lines of text
Abbr=
Zero or more lines of text
Field A=1
Field B=0
Zero or more lines of text
Hidden=N
[Text-FCT-FCTVALUEXXXX-IA-Note]
One or more note lines
[FCT-FCT-FCTVALUEZ-IE-DETAIL]
Zero or more lines of text
[FCT-FCT-FCTVALUEQ-IA-DETAIL]
Zero or more lines of text
[FCT-_FCTVALUEY-IA]
Name=value
Zero or more lines of text
Label=value
Zero or more lines of text
Field A=1
Abbr=value
Field A=1
Zero or more lines of text
Hidden=N
I need to find sections like this:
[FCT-FCTVALUEXXXX-IA]
Name=value
Label = value
Zero or more lines of text
Abbr=
Zero or more lines of text
Field A=1
Field B=0
Zero or more lines of text
Hidden=N
and extract FCT-FCTVALUEXXXX-AA, Name, Label, Abbr, Field A and B and Hidden, and then find a corresponding section (if it exists):
[Text-FCT-FCTVALUEXXXX-IA-Note]
One or more note lines
end extract the Note lines as a single string.
I don't care about the sections
[FCT-FCT-FCTVALUEZ-IE-DETAIL]
Zero or more lines of text
All three sorts of sections can appear anywhere in the file, including right at the end, and there's no predictable relationship in position between the sections.
The order of Abbr and Fields A and B cannot be guaranteed but they always appear after Name and Label and before Hidden.
What I have so far:
strParse = "(%[FCT%-.-%-)([IF])([EA])%]%c+Name=(.-)%c.-Label=(.-)%c(.-)Hidden=(%a)%c" --cant pull everything out at once because the order of some fields is not predictable
for id, rt, ft, name, label, detail, hidden in strFacts:gmatch(strParse) do
--extract details
abbr=detail:match("Abbr=(.-)%c") --may be blank
if abbr == nil then abbr = "" end
FieldA = detail:match("Field A=(%d)")
FieldB = detail:match("Field B=(%d)")
--need to sanitise id which could have a bunch of extraneous material tacked on the front and use it to get the Note
ident=id:match(".*(%[FCT%-.-%-$)")..rt..ft
Note = ParseAutonote(ident) --this is a function to parse the note which I've yet to test so a dummy function returns ""
tblResults[name]={ident, rt, ft, name, label, abbr, FieldA, FieldB, hidden, note}
end
Most of it works OK (after many hours of working on it), but the piece that isn't working is:
(".*(%[FCT%-.-%-$)")
which is supposed to pull out the final occurrence of FCT-sometext-
in the string id
My logic: anchor the search to the end of the string and capture the shortest possible string beginning with "[FCT-" and ending with "-" at the end of the string.
Given a value of either "[FCT-_ABCD-PDQR-" or
"[FCT-XYZ-DETAIL]lines of text[FCT-_ABCD-PDQR-" it returns nil when I want it to return "FCT-_ABCD-PDQR-". (Note ABCD, PDQR etc can be any length of text containing Alpha, - and _).
As you discovered yourself (".*(%[FCT%-.-%-)$") works the way you want,
where (".*(%[FCT%-.-%-$)") does not. $ and ^ are anchors and must come at the end or beginning of the pattern, they can not appear inside a capture closure.
When the anchor characters appear anywhere else in the pattern they will be part of the string you are looking for, excluding cases where ^ is used in a set to exclude chars i.e.: excluding upper-case chars [^A-Z]
Here are examples of the pattern matching using the an example string and the pattern from your question.
print(string.match("[FCT-_ABCD-PDQR-", (".*(%[FCT%-.-%-$)"))) -- initial pattern
> nil
print(string.match("[FCT-_ABCD-PDQR-$", (".*(%[FCT%-.-%-$)"))) -- $ added to end of string
> [FCT-_ABCD-PDQR-$
print(string.match("[FCT-_ABCD-PDQR-", (".*(%[FCT%-.-%-)$"))) -- $ moved to end of pattern
> [FCT-_ABCD-PDQR-

Extracting text from APA citation

I have a spreadsheet containing APA citation style text and I want to split them into author(s), date, and title.
An example of a citation would be:
Parikka, J. (2010). Insect Media: An Archaeology of Animals and Technology. Minneapolis: Univ Of Minnesota Press.
Given this string is in field I2 I managed to do the following:
Name: =LEFT(I2, FIND("(", I2)-1) yields Parikka, J.
Date: =MID(I2,FIND("(",I2)+1,FIND(")",I2)-FIND("(",I2)-1) yields 2010
However, I am stuck at extracting the name of the title Insect Media: An Archaeology of Animals and Technology.
My current formula =MID(I2,FIND(").",I2)+2,FIND(").",I2)-FIND(".",I2)) only returns the title partially - the output should show every character between ).and the following ..
I tried =REGEXEXTRACT(I2, "\)\.\s(.*[^\.])\.\s" ) and this generally works but does not stop at the first ". " - Like with this example:
Sanders, E. B.-N., Brandt, E., & Binder, T. (2010). A framework for organizing the tools and techniques of participatory design. In Proceedings of the 11th biennial participatory design conference (pp. 195–198). ACM. Retrieved from http://dl.acm.org/citation.cfm?id=1900476
Where is the mistake?
The title can be found (in the two examples you've given, at least) with this:
=MID(I2,find("). ",I2)+3,find(". ",I2,find("). ",I2)+3)-(find("). ",I2)+3)+1)
In English: Get the substring starting after the first occurrence of )., up to and including the first occurrence of . following.
If you wish to use REGEXEXTRACT, then this works (on your two examples). (You can also see a Regex101 demo.):
=REGEXEXTRACT(I3,"(?:.*\(\d{4}\)\.\s)([^.]*\.)(?: .*)")
Where is the mistake?
In your expression, you were capturing (.*[^\.]), which greedily includes any number of characters followed by a character in the character class not (backslash or dot), which means that multiple sentences can be captured. The expression finished with \.\s, which wasn't captured, so the capture group would end before a period-then-space, rather than including it.
Try:
=split(SUBSTITUTE(SUBSTITUTE(I2, "(",""), ")", ""),".")
If you don't replace the parentheses around 2010, it thinks it is a negative number -2010.
For your Title try adding index split to your existing formula:
=index(split(REGEXEXTRACT(A5, "\)\.\s(.*[^\.])\.\s" ),"."),0,1)&"."

Is it possible to display an in-line image?

Article http://runrev.com/newsletter/june/issue135/newsletter4.php shows how to display a table in a text field. Is it as well possible to display in-line images?
You'll have to mess with the htmltext of the field in order to insert the online images, but it can be done. Put the htmltext of the field into a variable, then insert a line of html, as in
put "<img src=" & quote & "http://www.site.com/image.png" & quote & ">" after line x of tHtmlText
and then set the htmltext of the field back to tHtmlText
If the image is in your stack, you can use
put "%" into fld 1
set the imageSource of char 1 of fld 1 to 1014
Where % is an arbitrary character and 1014 is the image id of an arbitrary image. You can set the imageSource of any character in a field.

Numbered anchors in doxygen

I have quite a lot of anchors to picture in doxygen, e.g.
\anchor pic_foo
\image html foo.gif "My Caption"
\anchor pic_bar
\image html bar.gif "My Caption"
Everytime when I use \ref to link one of those, I have to make up
some nice description so the raw name of the anchor doesn't appear in
output.
Is it possible to have something like numbered anchors in doxygen
where the link text will be the number of that anchor? Ideally
something like:
\anchor pic_foo
\image html foo.gif "My Caption"
\anchor pic_bar
\image html bar.gif "My Caption"
As Figure \ref pic_foo shows... Figure \ref pic_bar is...
should ideally translate to:
As Figure 1 shows... Figure 2 is...
where the number is the link. I would be happy with every kind of counting scheme (documentation global or page local).
I don't think that automatic number of figures, either within a page or across the whole documentation, is possible with doxygen (I would be happy to be corrected here). However, an easy solution to your question is the replace your anchor text with spelt out numbers, i.e. "one", "two", "three"... etc. Alternatively, if you have lots of figures you could use Roman numerals. Plain numbers don't seem to work as anchor links.
Your example will then become, with additional text in the figure captions,
\anchor one
\image html foo.gif "Figure one: My Caption"
\anchor two
\image html bar.gif "Figure two: My Caption"
As Figure \ref one shows... Figure \ref two is...
resulting in
Here Figure one shows... Figure two is...
with one and two hyperlinks to your figures.
You can then define a alias in your configuration file, say \fref, defined to be Figure \ref which will automatically preceed the hyperlinked numbers with the text "Figure".
Is this solution acceptable? The only other alternative I can think of involves post processing the doxygen output, but the above solution is by far the simplest.
Update
The following Python code will transform anchor references to an incrementing counter:
# Test documentation.
s = r"""
\anchor pic_foo
\image html foo.gif "My Caption"
\anchor pic_bar
\image html bar.gif "My Caption"
As Figure \ref pic_foo shows... Figure \ref pic_bar is...
"""
# Split string into a list of lines.
s = s.split('\n')
# Dictionaries for mapping anchor names to an incrementing counter.
d = {}
numbers = {1: 'one',
2 : 'two',
3 : 'three'}
counter = 1
# Find all anchor links and map to the next counter value.
for line in s:
if r'\anchor' in line:
d[line.split(r'\anchor ')[1]] = numbers[counter]
counter += 1
# Reform original string.
s = '\n'.join(s)
# Replace anchor links with appropriate counter value.
for key, value in d.items():
s = s.replace(key, value)
print s
Running this script results in the output
\anchor one
\image html foo.gif "My Caption"
\anchor two
\image html bar.gif "My Caption"
As Figure \ref one shows... Figure \ref two is...
It is trivial to modify the above script to read from standard input and write to standard out, so this can easily be used in conjunction with the INPUT_FILTER configuration file option.
One thing to note is that the dictionary numbers has to be extended to allow for more than three figures to be included. This is again trivial, but probably not easily scalable. Solutions for mapping from arbitrary numbers to the appropriate word(s) are available (see other questions on this site) so I haven't bothered to implement this here.

Resources