Re: How to define in-text CSL format for HTML citations?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Christoph Bersch
I only subscribed to the mailinglist after having read this message,  
so please forgive me the bad citation.

Carl Boettiger wrote:
> Given the importance of web-based formats and the ease of using CSL to
> generate citations in markdown and html documents with tools such as
> pandoc, it seems natural that individuals would want to style in-text
> citations not only to reflect journal norms of author surnames etc, but
> include such features as actual links, perhaps add `title` attributes for
> mouse-over effects, and so forth.  If this is not possible in the current
> implementation, is this something CSL might address in the future?

I'm also having problems with this. I'm currently implementing a  
CSL-based solution for displaying publication lists on a homepage. For  
this I also want to include some links.

I think it is correct, that CSL shouldn't depend on the selected  
output format, so my proposal would be to have a syntax like

<macro name="url-macro">
     <choose>
         <if variable="DOI">
             <text variable="DOI" prefix="http://dx.doi.org/"/>
         </if>
         <else>
             <text variable="URL"/>
         </else>
     </choose>
</macro>

<group href="url-macro">
     <text variable="title" />
</group>

This would allow the processor to wrap a certain text part with a  
link, or ignore it. This wouldn't depend on the output format.

Also the argument, that one would get even more styles, which also  
differ in the linking behavior doesn't hold in my opinion. My current  
solution is much worse :(

The solution provided by Sebastian doesn't work, because it is invalid  
XML (using prefix="<a href='"). I don't know how this could be escaped  
properly to be read in correctly, and still have the correct tags in  
the output.

At the moment I use intermediate markers of the kind prefix="{{a  
href='" which are then replaced in a post-processing step by '<'. This  
results in ugly one-time-styles. I would really like to see some kind  
of linking features like proposed above.

Best regards,
Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Sebastian Karcher
> The solution provided by Sebastian doesn't work, because it is invalid
> XML (using prefix="<a href='").
This is mainly a technical discussion list for an XML based format, so
I assume people know how to escape XML. See e.g.
http://www.freeformatter.com/xml-escape.html


On Thu, Jun 12, 2014 at 1:49 AM, Christoph Bersch <[hidden email]> wrote:

> I only subscribed to the mailinglist after having read this message,
> so please forgive me the bad citation.
>
> Carl Boettiger wrote:
>> Given the importance of web-based formats and the ease of using CSL to
>> generate citations in markdown and html documents with tools such as
>> pandoc, it seems natural that individuals would want to style in-text
>> citations not only to reflect journal norms of author surnames etc, but
>> include such features as actual links, perhaps add `title` attributes for
>> mouse-over effects, and so forth.  If this is not possible in the current
>> implementation, is this something CSL might address in the future?
>
> I'm also having problems with this. I'm currently implementing a
> CSL-based solution for displaying publication lists on a homepage. For
> this I also want to include some links.
>
> I think it is correct, that CSL shouldn't depend on the selected
> output format, so my proposal would be to have a syntax like
>
> <macro name="url-macro">
>      <choose>
>          <if variable="DOI">
>              <text variable="DOI" prefix="http://dx.doi.org/"/>
>          </if>
>          <else>
>              <text variable="URL"/>
>          </else>
>      </choose>
> </macro>
>
> <group href="url-macro">
>      <text variable="title" />
> </group>
>
> This would allow the processor to wrap a certain text part with a
> link, or ignore it. This wouldn't depend on the output format.
>
> Also the argument, that one would get even more styles, which also
> differ in the linking behavior doesn't hold in my opinion. My current
> solution is much worse :(
>
> The solution provided by Sebastian doesn't work, because it is invalid
> XML (using prefix="<a href='"). I don't know how this could be escaped
> properly to be read in correctly, and still have the correct tags in
> the output.
>
> At the moment I use intermediate markers of the kind prefix="{{a
> href='" which are then replaced in a post-processing step by '<'. This
> results in ugly one-time-styles. I would really like to see some kind
> of linking features like proposed above.
>
> Best regards,
> Christoph
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> xbiblio-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel



--
Sebastian Karcher
Ph.D. Candidate
Department of Political Science
Northwestern University

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Christoph Bersch

Zitat von Sebastian Karcher <[hidden email]>:

>> The solution provided by Sebastian doesn't work, because it is invalid
>> XML (using prefix="<a href='").
> This is mainly a technical discussion list for an XML based format, so
> I assume people know how to escape XML. See e.g.
> http://www.freeformatter.com/xml-escape.html

I know how to escape XML, but not how escaping in this specific case  
would solve the problem, i.e. get a valid <br/> tag after processing.  
Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for  
testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a  
line break, what one would need.

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Bruce D'Arcus-3

Maybe one of those days, but I'm not following this discussion at all.

Can you just describe what you're trying to do, and we can talk about possible solutions and workarounds?

On Jun 12, 2014 12:00 PM, "Christoph Bersch" <[hidden email]> wrote:

Zitat von Sebastian Karcher <[hidden email]>:

>> The solution provided by Sebastian doesn't work, because it is invalid
>> XML (using prefix="<a href='").
> This is mainly a technical discussion list for an XML based format, so
> I assume people know how to escape XML. See e.g.
> http://www.freeformatter.com/xml-escape.html

I know how to escape XML, but not how escaping in this specific case
would solve the problem, i.e. get a valid <br/> tag after processing.
Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for
testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a
line break, what one would need.

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

fbennett
In reply to this post by Christoph Bersch
Christoph,

That's right. Any text that reaches the processor through CSL code will be escaped according to the output format. The only way to do this through CSL markup is what you have been doing (i.e. setting a slug in the CSL, and then replacing it in each citation after it is rendered).

Adding wrapper markup is currently out of scope for CSL proper, but processors may offer their own hooks to accomplish this. If you're running citeproc-node, you'll be running citeproc-js, which could be extended to support field-level wrappers with a small amount of work, thanks to groundwork done to support Steve Ridout's work on the CSL Visual Editor.

The business end of the hook is in formats.js, in the "@showid/true" function:

    https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112

As you can tell from the source, this is currently just hard-wired code that sets a span on the output. The span is used in the Visual Editor to navigate from an element in a rendered citation back to its source in CSL code. It is enabled by a processor option (csl_reverse_lookup_support), which (unlike other options) must be set in the source code itself, _before_ building the engine:

    https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112

We can exploit this code to support your use case (which I'm guessing will be very popular once supported). I think the way to do it would be to provide a hook on the processor that registers a callback to add a wrapper according to your preferences, based on the item data and the context of the item.

Does that sound like it would be useful?

Frank




On Fri, Jun 13, 2014 at 12:53 AM, Christoph Bersch <[hidden email]> wrote:

Zitat von Sebastian Karcher <[hidden email]>:

>> The solution provided by Sebastian doesn't work, because it is invalid
>> XML (using prefix="<a href='").
> This is mainly a technical discussion list for an XML based format, so
> I assume people know how to escape XML. See e.g.
> http://www.freeformatter.com/xml-escape.html

I know how to escape XML, but not how escaping in this specific case
would solve the problem, i.e. get a valid <br/> tag after processing.
Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for
testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a
line break, what one would need.

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Sebastian Karcher
right, what Frank says is the broader answer to your question. As both
me and Bruce said in the original thread, the issue is not that this
isn't an understandable and relevant request, but that the CSL
specifications aren't the right place for it. This needs to happen in
the various processors, some of which, as Frank points out, are well
set-up for this.

My guess would be that with three flags, something like
"hyperlink_title," "hyperlink_DOI," and "hyperlink_URL" you'd have
most bases covered.

As for the escaped/unescaped html in affixes: The original poster had
html in affixes, so I assumed he was happy with the output. My
suggestion was just a tweak on something he posted and I was quite
clear that I didn't consider it a general solution.



On Thu, Jun 12, 2014 at 4:24 PM, Frank Bennett <[hidden email]> wrote:

> Christoph,
>
> That's right. Any text that reaches the processor through CSL code will be
> escaped according to the output format. The only way to do this through CSL
> markup is what you have been doing (i.e. setting a slug in the CSL, and then
> replacing it in each citation after it is rendered).
>
> Adding wrapper markup is currently out of scope for CSL proper, but
> processors may offer their own hooks to accomplish this. If you're running
> citeproc-node, you'll be running citeproc-js, which could be extended to
> support field-level wrappers with a small amount of work, thanks to
> groundwork done to support Steve Ridout's work on the CSL Visual Editor.
>
> The business end of the hook is in formats.js, in the "@showid/true"
> function:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> As you can tell from the source, this is currently just hard-wired code that
> sets a span on the output. The span is used in the Visual Editor to navigate
> from an element in a rendered citation back to its source in CSL code. It is
> enabled by a processor option (csl_reverse_lookup_support), which (unlike
> other options) must be set in the source code itself, _before_ building the
> engine:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> We can exploit this code to support your use case (which I'm guessing will
> be very popular once supported). I think the way to do it would be to
> provide a hook on the processor that registers a callback to add a wrapper
> according to your preferences, based on the item data and the context of the
> item.
>
> Does that sound like it would be useful?
>
> Frank
>
>
>
>
> On Fri, Jun 13, 2014 at 12:53 AM, Christoph Bersch <[hidden email]>
> wrote:
>>
>>
>> Zitat von Sebastian Karcher <[hidden email]>:
>>
>> >> The solution provided by Sebastian doesn't work, because it is invalid
>> >> XML (using prefix="<a href='").
>> > This is mainly a technical discussion list for an XML based format, so
>> > I assume people know how to escape XML. See e.g.
>> > http://www.freeformatter.com/xml-escape.html
>>
>> I know how to escape XML, but not how escaping in this specific case
>> would solve the problem, i.e. get a valid <br/> tag after processing.
>> Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for
>> testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a
>> line break, what one would need.
>>
>> Christoph
>>
>>
>>
>> ------------------------------------------------------------------------------
>> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
>> Find What Matters Most in Your Big Data with HPCC Systems
>> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
>> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
>> http://p.sf.net/sfu/hpccsystems
>> _______________________________________________
>> xbiblio-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> xbiblio-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>



--
Sebastian Karcher
Ph.D. Candidate
Department of Political Science
Northwestern University

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

aurimas

Though, I think, you would want to be flexible enough to be able to hyperlink other identifiers, like PMID/PMCID. Maybe an attribute like "hyperlink"  (on group or text/number/etc. nodes) could reference a macro that would generate the actual url.

On Jun 12, 2014 6:55 PM, "Sebastian Karcher" <[hidden email]> wrote:
right, what Frank says is the broader answer to your question. As both
me and Bruce said in the original thread, the issue is not that this
isn't an understandable and relevant request, but that the CSL
specifications aren't the right place for it. This needs to happen in
the various processors, some of which, as Frank points out, are well
set-up for this.

My guess would be that with three flags, something like
"hyperlink_title," "hyperlink_DOI," and "hyperlink_URL" you'd have
most bases covered.

As for the escaped/unescaped html in affixes: The original poster had
html in affixes, so I assumed he was happy with the output. My
suggestion was just a tweak on something he posted and I was quite
clear that I didn't consider it a general solution.



On Thu, Jun 12, 2014 at 4:24 PM, Frank Bennett <[hidden email]> wrote:
> Christoph,
>
> That's right. Any text that reaches the processor through CSL code will be
> escaped according to the output format. The only way to do this through CSL
> markup is what you have been doing (i.e. setting a slug in the CSL, and then
> replacing it in each citation after it is rendered).
>
> Adding wrapper markup is currently out of scope for CSL proper, but
> processors may offer their own hooks to accomplish this. If you're running
> citeproc-node, you'll be running citeproc-js, which could be extended to
> support field-level wrappers with a small amount of work, thanks to
> groundwork done to support Steve Ridout's work on the CSL Visual Editor.
>
> The business end of the hook is in formats.js, in the "@showid/true"
> function:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> As you can tell from the source, this is currently just hard-wired code that
> sets a span on the output. The span is used in the Visual Editor to navigate
> from an element in a rendered citation back to its source in CSL code. It is
> enabled by a processor option (csl_reverse_lookup_support), which (unlike
> other options) must be set in the source code itself, _before_ building the
> engine:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> We can exploit this code to support your use case (which I'm guessing will
> be very popular once supported). I think the way to do it would be to
> provide a hook on the processor that registers a callback to add a wrapper
> according to your preferences, based on the item data and the context of the
> item.
>
> Does that sound like it would be useful?
>
> Frank
>
>
>
>
> On Fri, Jun 13, 2014 at 12:53 AM, Christoph Bersch <[hidden email]>
> wrote:
>>
>>
>> Zitat von Sebastian Karcher <[hidden email]>:
>>
>> >> The solution provided by Sebastian doesn't work, because it is invalid
>> >> XML (using prefix="<a href='").
>> > This is mainly a technical discussion list for an XML based format, so
>> > I assume people know how to escape XML. See e.g.
>> > http://www.freeformatter.com/xml-escape.html
>>
>> I know how to escape XML, but not how escaping in this specific case
>> would solve the problem, i.e. get a valid <br/> tag after processing.
>> Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for
>> testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a
>> line break, what one would need.
>>
>> Christoph
>>
>>
>>
>> ------------------------------------------------------------------------------
>> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
>> Find What Matters Most in Your Big Data with HPCC Systems
>> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
>> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
>> http://p.sf.net/sfu/hpccsystems
>> _______________________________________________
>> xbiblio-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> xbiblio-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>



--
Sebastian Karcher
Ph.D. Candidate
Department of Political Science
Northwestern University

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

fbennett
On Fri, Jun 13, 2014 at 9:11 AM, Aurimas Vinckevicius <[hidden email]> wrote:

Though, I think, you would want to be flexible enough to be able to hyperlink other identifiers, like PMID/PMCID. Maybe an attribute like "hyperlink"  (on group or text/number/etc. nodes) could reference a macro that would generate the actual url.

With a callback against the item in context, you could even provide RDFa wrappers on the individual elements. It would be a little tricky to get it right, but the effects against some of the new statutory archives in the UK, the US and Europe could be really nice. It would open a path to linking into author profiles on ORCID eventually as well.

 
On Jun 12, 2014 6:55 PM, "Sebastian Karcher" <[hidden email]> wrote:
right, what Frank says is the broader answer to your question. As both
me and Bruce said in the original thread, the issue is not that this
isn't an understandable and relevant request, but that the CSL
specifications aren't the right place for it. This needs to happen in
the various processors, some of which, as Frank points out, are well
set-up for this.

My guess would be that with three flags, something like
"hyperlink_title," "hyperlink_DOI," and "hyperlink_URL" you'd have
most bases covered.

As for the escaped/unescaped html in affixes: The original poster had
html in affixes, so I assumed he was happy with the output. My
suggestion was just a tweak on something he posted and I was quite
clear that I didn't consider it a general solution.



On Thu, Jun 12, 2014 at 4:24 PM, Frank Bennett <[hidden email]> wrote:
> Christoph,
>
> That's right. Any text that reaches the processor through CSL code will be
> escaped according to the output format. The only way to do this through CSL
> markup is what you have been doing (i.e. setting a slug in the CSL, and then
> replacing it in each citation after it is rendered).
>
> Adding wrapper markup is currently out of scope for CSL proper, but
> processors may offer their own hooks to accomplish this. If you're running
> citeproc-node, you'll be running citeproc-js, which could be extended to
> support field-level wrappers with a small amount of work, thanks to
> groundwork done to support Steve Ridout's work on the CSL Visual Editor.
>
> The business end of the hook is in formats.js, in the "@showid/true"
> function:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> As you can tell from the source, this is currently just hard-wired code that
> sets a span on the output. The span is used in the Visual Editor to navigate
> from an element in a rendered citation back to its source in CSL code. It is
> enabled by a processor option (csl_reverse_lookup_support), which (unlike
> other options) must be set in the source code itself, _before_ building the
> engine:
>
>
> https://bitbucket.org/fbennett/citeproc-js/src/0948536cb1b541aea81b2b94ba98682c8692bcf6/src/formats.js?at=default#cl-112
>
> We can exploit this code to support your use case (which I'm guessing will
> be very popular once supported). I think the way to do it would be to
> provide a hook on the processor that registers a callback to add a wrapper
> according to your preferences, based on the item data and the context of the
> item.
>
> Does that sound like it would be useful?
>
> Frank
>
>
>
>
> On Fri, Jun 13, 2014 at 12:53 AM, Christoph Bersch <[hidden email]>
> wrote:
>>
>>
>> Zitat von Sebastian Karcher <[hidden email]>:
>>
>> >> The solution provided by Sebastian doesn't work, because it is invalid
>> >> XML (using prefix="<a href='").
>> > This is mainly a technical discussion list for an XML based format, so
>> > I assume people know how to escape XML. See e.g.
>> > http://www.freeformatter.com/xml-escape.html
>>
>> I know how to escape XML, but not how escaping in this specific case
>> would solve the problem, i.e. get a valid <br/> tag after processing.
>> Using e.g. citeproc-node with something like suffix="&lt;br/&gt;" for
>> testing, gives me &#60;br/&#62;, which is a verbatim <br/> and not a
>> line break, what one would need.
>>
>> Christoph
>>
>>
>>
>> ------------------------------------------------------------------------------
>> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
>> Find What Matters Most in Your Big Data with HPCC Systems
>> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
>> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
>> http://p.sf.net/sfu/hpccsystems
>> _______________________________________________
>> xbiblio-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>
>
>
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> xbiblio-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
>



--
Sebastian Karcher
Ph.D. Candidate
Department of Political Science
Northwestern University

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel



------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Christoph Bersch
In reply to this post by fbennett
Frank, thanks for your reply.

Zitat von Frank Bennett <[hidden email]>:
>
> Adding wrapper markup is currently out of scope for CSL proper, but
> processors may offer their own hooks to accomplish this.

In my opinion, there isn't much difference between a `font-weight`,  
`display` and a potential `href` argument.

My use case is, that I want to generate different publication lists  
for our institute's homepage, and this should allow to wrap quite  
arbitrary parts of a bibentry with a link. So your proposal to add a  
hook to certain items propably wouldn't work straight away.

So, with an `href` argument, a possible part would look like

<group delimiter=" " href="DOI">
   <text variable="container-title" form="short" text-case="title"/>
   <group delimiter=", ">
     <text variable="volume" font-weight="bold"/>
     <group delimiter=" ">
       <text macro="page-or-number"/>
       <text macro="year-date" prefix="(" suffix=")"/>
     </group>
   </group>
</group>

As a workaround, I created two macros `doi-or-url-start` and  
`doi-or-url-stop` which allow to insert pseudo links, which are then  
post-processed with PHP. For reference, here are the snippets I  
currently use:

<macro name="doi-or-url">
   <choose>
     <if variable="URL">
       <text variable="URL" />
     </if>
     <else-if variable="DOI">
       <text variable="DOI" prefix="http://dx.doi.org/" />
     </else-if>
   </choose>
</macro>
<macro name="doi-or-url-start">
   <choose>
     <if variable="URL DOI" match="any">
       <text macro="doi-or-url" prefix="{{a href='" suffix="'}}"/>
     </if>
   </choose>
</macro>
<macro name="doi-or-url-stop">
   <choose>
     <if variable="URL DOI" match="any">
       <text value="{{/a}}"/>
     </if>
   </choose>
</macro>
<group delimiter=" ">
   <text macro="doi-or-url-start"/>
   <text variable="container-title" form="short" text-case="title"/>
   <group delimiter=", ">
   <text variable="volume" font-weight="bold"/>
   <group delimiter=" ">
     <text macro="page-or-number"/>
     <text macro="year-date" prefix="(" suffix=")"/>
   </group>
   </group>
   <text macro="doi-or-url-stop"/>
</group>

For the replacements of the '{{...' stuff I use the following regular  
expressions:

function replaceLinks($text) {
   $pattern = array('/{{(a href=.*?)}}(.*?){{\/a}}/',
                    '/{{(\/?(?:[hH][1-6]|[a-zA-Z]+))\/?}}/');
   $replacement = array('<\1>\2</a>',
                        '<\1>');
   return preg_replace($pattern, $replacement, $text);
}


Best regards,
Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

fbennett
On Tue, Jun 17, 2014 at 5:57 PM, Christoph Bersch <[hidden email]> wrote:
Frank, thanks for your reply.

Zitat von Frank Bennett <[hidden email]>:
>
> Adding wrapper markup is currently out of scope for CSL proper, but
> processors may offer their own hooks to accomplish this.

In my opinion, there isn't much difference between a `font-weight`,
`display` and a potential `href` argument.

They look similar in HTML markup, but the first two are purely about display, and the last requires information from the item data. Also, you might place the first two anywhere in a citation, but the last needs to go exclusively on a node that renders a variable (if we are going to render fine-grained linking, which we should provide for -- to cover RDFa).


My use case is, that I want to generate different publication lists
for our institute's homepage, and this should allow to wrap quite
arbitrary parts of a bibentry with a link. So your proposal to add a
hook to certain items propably wouldn't work straight away.

Yes, you would need to write a small snippet of JavaScript code. When the adjustments to the processor are done, I'll post instructions.
 

So, with an `href` argument, a possible part would look like

<group delimiter=" " href="DOI">
   <text variable="container-title" form="short" text-case="title"/>
   <group delimiter=", ">
     <text variable="volume" font-weight="bold"/>
     <group delimiter=" ">
       <text macro="page-or-number"/>
       <text macro="year-date" prefix="(" suffix=")"/>
     </group>
   </group>
</group>

If you want to wrap the entire bib entry in a single like like that, it's already supported -- that is what the code added for Philip Lord's project does.

Coding the wrapper and variable into the CSL would make things quite stiff. People might want to link with an anchor around the cite, or place a button next to the cite, or link to a resolver with a selection of cite details, or just apply a highlight to some portion the cite, conditioned on its content. Or link to the ORCID ids or profiles of all authors on an item in a rollover menu (including authors dropped by et al. truncation).

A hook can be made to cover any of those use cases fairly easily.

 
As a workaround, I created two macros `doi-or-url-start` and
`doi-or-url-stop` which allow to insert pseudo links, which are then
post-processed with PHP. For reference, here are the snippets I
currently use:

<macro name="doi-or-url">
   <choose>
     <if variable="URL">
       <text variable="URL" />
     </if>
     <else-if variable="DOI">
       <text variable="DOI" prefix="http://dx.doi.org/" />
     </else-if>
   </choose>
</macro>
<macro name="doi-or-url-start">
   <choose>
     <if variable="URL DOI" match="any">
       <text macro="doi-or-url" prefix="{{a href='" suffix="'}}"/>
     </if>
   </choose>
</macro>
<macro name="doi-or-url-stop">
   <choose>
     <if variable="URL DOI" match="any">
       <text value="{{/a}}"/>
     </if>
   </choose>
</macro>
<group delimiter=" ">
   <text macro="doi-or-url-start"/>
   <text variable="container-title" form="short" text-case="title"/>
   <group delimiter=", ">
   <text variable="volume" font-weight="bold"/>
   <group delimiter=" ">
     <text macro="page-or-number"/>
     <text macro="year-date" prefix="(" suffix=")"/>
   </group>
   </group>
   <text macro="doi-or-url-stop"/>
</group>

For the replacements of the '{{...' stuff I use the following regular
expressions:

function replaceLinks($text) {
   $pattern = array('/{{(a href=.*?)}}(.*?){{\/a}}/',
                    '/{{(\/?(?:[hH][1-6]|[a-zA-Z]+))\/?}}/');
   $replacement = array('<\1>\2</a>',
                        '<\1>');
   return preg_replace($pattern, $replacement, $text);
}

That was what I understood. A hook function will be easier for you to work with, once it's running in the processor.

More news in a few days!

Frank

 


Best regards,
Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

Christoph Bersch

Zitat von Frank Bennett <[hidden email]>:

> On Tue, Jun 17, 2014 at 5:57 PM, Christoph Bersch <[hidden email]> wrote:
>
>> My use case is, that I want to generate different publication lists
>> for our institute's homepage, and this should allow to wrap quite
>> arbitrary parts of a bibentry with a link. So your proposal to add a
>> hook to certain items propably wouldn't work straight away.
>>
>
> Yes, you would need to write a small snippet of JavaScript code. When the
> adjustments to the processor are done, I'll post instructions.

great.

> Coding the wrapper and variable into the CSL would make things quite stiff.
> People might want to link with an anchor around the cite, or place a button
> next to the cite, or link to a resolver with a selection of cite details,
> or just apply a highlight to some portion the cite, conditioned on its
> content. Or link to the ORCID ids or profiles of all authors on an item in
> a rollover menu (including authors dropped by et al. truncation).

I see

> More news in a few days!

Thank you!

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

fbennett
The latest processor release tag (1.0.531) should give you a hook for adding link anchors in HTML output. Here is a sample hook function, which should be defined as an element on the "sys" object, before the processor is instantiated:

  sys.variableWrapper = function (itemData, variableNames, str, punct) {
      if (variableNames[0] === 'title' && itemData.URL) {
          return '<a href="' + itemData.URL + '">' + str + '</a>' + punct;
      } else {
          return (str + punct);
      }
  }

itemData is the input item, in CSL JSON format. Simple fields are easy, for names you may need to do some study and sleuthing to figure out how they work.

variableNames is an array of variable names. Normally this will be just a single name, but cs:names nodes can specify multiple creator types (such as editor and translator).

str is the field content, less any trailing punctuation applied by CSL.

punct is an empty string or a single punctuation character.

If you set that function and run the new processor in your current environment, it should just work. That's what it says here, anyway. :-)

Frank






On Tue, Jun 17, 2014 at 8:56 PM, Christoph Bersch <[hidden email]> wrote:

Zitat von Frank Bennett <[hidden email]>:
> On Tue, Jun 17, 2014 at 5:57 PM, Christoph Bersch <[hidden email]> wrote:
>
>> My use case is, that I want to generate different publication lists
>> for our institute's homepage, and this should allow to wrap quite
>> arbitrary parts of a bibentry with a link. So your proposal to add a
>> hook to certain items propably wouldn't work straight away.
>>
>
> Yes, you would need to write a small snippet of JavaScript code. When the
> adjustments to the processor are done, I'll post instructions.

great.

> Coding the wrapper and variable into the CSL would make things quite stiff.
> People might want to link with an anchor around the cite, or place a button
> next to the cite, or link to a resolver with a selection of cite details,
> or just apply a highlight to some portion the cite, conditioned on its
> content. Or link to the ORCID ids or profiles of all authors on an item in
> a rollover menu (including authors dropped by et al. truncation).

I see

> More news in a few days!

Thank you!

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to define in-text CSL format for HTML citations?

fbennett
(You may want access to the state object inside that function, to inspect options.and processor globals; but let me know how it works in the current configuration before we extend it).


On Thu, Jun 19, 2014 at 12:05 AM, Frank Bennett <[hidden email]> wrote:
The latest processor release tag (1.0.531) should give you a hook for adding link anchors in HTML output. Here is a sample hook function, which should be defined as an element on the "sys" object, before the processor is instantiated:

  sys.variableWrapper = function (itemData, variableNames, str, punct) {
      if (variableNames[0] === 'title' && itemData.URL) {
          return '<a href="' + itemData.URL + '">' + str + '</a>' + punct;
      } else {
          return (str + punct);
      }
  }

itemData is the input item, in CSL JSON format. Simple fields are easy, for names you may need to do some study and sleuthing to figure out how they work.

variableNames is an array of variable names. Normally this will be just a single name, but cs:names nodes can specify multiple creator types (such as editor and translator).

str is the field content, less any trailing punctuation applied by CSL.

punct is an empty string or a single punctuation character.

If you set that function and run the new processor in your current environment, it should just work. That's what it says here, anyway. :-)

Frank






On Tue, Jun 17, 2014 at 8:56 PM, Christoph Bersch <[hidden email]> wrote:

Zitat von Frank Bennett <[hidden email]>:
> On Tue, Jun 17, 2014 at 5:57 PM, Christoph Bersch <[hidden email]> wrote:
>
>> My use case is, that I want to generate different publication lists
>> for our institute's homepage, and this should allow to wrap quite
>> arbitrary parts of a bibentry with a link. So your proposal to add a
>> hook to certain items propably wouldn't work straight away.
>>
>
> Yes, you would need to write a small snippet of JavaScript code. When the
> adjustments to the processor are done, I'll post instructions.

great.

> Coding the wrapper and variable into the CSL would make things quite stiff.
> People might want to link with an anchor around the cite, or place a button
> next to the cite, or link to a resolver with a selection of cite details,
> or just apply a highlight to some portion the cite, conditioned on its
> content. Or link to the ORCID ids or profiles of all authors on an item in
> a rollover menu (including authors dropped by et al. truncation).

I see

> More news in a few days!

Thank you!

Christoph


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel



------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
xbiblio-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel