Difference between revisions of "Template:Arxiv"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mwtoews
(using WP:DOC)
(Rewrite to allow archive categories with new-style identifiers. Worked around a strange template bug; see comments)
Line 1: Line 1:
[[arXiv]]:[<!--
+
[[arXiv]]:{{#if:{{{archive|{{{2|}}}}}}
     -->http://arxiv.org/abs/<!--
+
  |{{#if:{{#pos:{{{id|{{{2}}}}}}|.}}
    -->{{#if: {{{archive|{{{2|}}}}}}<!--
+
     |[http://arxiv.org/abs/{{{id|{{{2|}}}}}} {{{id|{{{2|{&#123;{2}&#125;}}}}}}}] &#91;{{{archive|{{{1}}}}}}&#93;
      -->| {{{archive|{{{1}}}}}}/{{{id|{{{2}}}}}}<!--
+
    |[http://arxiv.org/abs/{{{archive|{{{1|}}}}}}/{{{id|{{{2|}}}}}} {{{archive|{{{1|{&#123;{1}&#125;}}}}}}}/{{{id|{{{2|{&#123;{2}&#125;} }}}}}}]
      -->| {{{id|{{{1}}}}}} }} <!-- URL ends here
+
  }}
    -->{{#if: {{{archive|{{{2|}}}}}}<!--
+
  |[http://arxiv.org/abs/{{{id|{{{1|}}}}}} {{{id|{{{1|{&#123;{1}&#125;}}}}}}}]
      -->| {{{archive|{{{1}}}}}}/{{{id|{{{2}}}}}}<!--
+
}}<noinclude>
      -->| {{{id|{{{1}}}}}} }}<!--
+
<!-- Explanation of the above line noise:
-->]<!--  end of external link
+
Remember, that the archive is the first, but optional, parameter.
--><noinclude>
+
The ID is {{{id|{{{2}}}}}} if a section is supplied, but {{{id|{{{1}}}}}} if not.
 +
A section is supplied if {{{archive|{{{2|}}}}}} is non-empty.  There are three cases (bottom to top in the above):
 +
1) id only.  Generate [http://arxiv.org/abs/id id].
 +
2) archive, with new-style ID (containing ., searched for using {{#pos:haystack|needle}})
 +
  Generate [http://archiv.org/abs/id id] &#91;archive&#93;.  (91 and 93 are [ and ])
 +
3) archive and ID, old-style
 +
  Generate [http://arxiv.org/abs/archive/id archive/id].
 +
The trailing conditionals on the innermost parameters (using {&#123;{ and }&#125;} to prevent interpretation as parameters)) appear to be needed to produce sensible output on the template page.  Deleting them produces STRANGE results.  "{{#if:x|[http://example.com/ {{{1}}}]}}" is a minimal example.  The given text is used so the result looks like a missing template parameter.  Note that in the URLs, the alternative is simply blank.  Wiki-guru requested, but what's there works for now.
 +
-->
 
{{template doc}}
 
{{template doc}}
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
</noinclude>

Revision as of 07:01, 7 July 2007

arXiv:{{{1}}}

Template documentation[view] [edit] [history] [purge]

Purpose

Provides a uniform method of formatting arXiv links, and makes it simpler to update if the format of those links changes in future.

Usage

This template can be used in the following ways:

The parameters have the following meaning:

  • |1= or |id= or specifies the ID of the particular entry

Examples

Markup Renders as
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]

Citation Style 1 and Citation Style 2 templates include a |arxiv= parameter with the same function.

Deprecated usage

These calling sequences were used for before 1 April 2007 when the new identifiers that removed the archive class from the identifiers themselves.

The older entries can still be linked to by removing the delimiting "." and subject class or category specifier from the identifier and delimiting the remaining archive specifier and the rest of the identifier (the dated entry number) with a slash ("/").

The parameters have the following meaning:

  • |1= or |archive= specifies the arXiv archive (full list here) using the abbreviated code
  • |2= or |id= specifies the ID of the particular entry

Markup Renders as
[[:Template:MultiReplace]]
[[:Template:MultiReplace]]

See also