mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Implement "key only" citation style
File format change.
This commit is contained in:
parent
d401a46267
commit
327602d01d
@ -7,6 +7,12 @@ changes happened in particular if possible. A good example would be
|
|||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
2017-01-13 Jürgen Spitzmüller <spitz@lyx.org>
|
||||||
|
* Format incremented to 529:
|
||||||
|
\begin_inset CommandInset citation
|
||||||
|
New LatexCommand value: keyonly -> outputs only the key,
|
||||||
|
without any cite command.
|
||||||
|
|
||||||
2017-01-08 Jürgen Spitzmüller <spitz@lyx.org>
|
2017-01-08 Jürgen Spitzmüller <spitz@lyx.org>
|
||||||
* Format incremented to 528: Biblatex support
|
* Format incremented to 528: Biblatex support
|
||||||
- New buffer param options:
|
- New buffer param options:
|
||||||
|
@ -26,6 +26,7 @@ DefaultBiblio plain
|
|||||||
CiteEngine default
|
CiteEngine default
|
||||||
cite[]
|
cite[]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
@ -46,6 +47,8 @@ CiteFormat default
|
|||||||
#
|
#
|
||||||
_notcited not cited
|
_notcited not cited
|
||||||
_addtobib Add to bibliography only.
|
_addtobib Add to bibliography only.
|
||||||
|
_keyonly Key only.
|
||||||
|
_key Key
|
||||||
|
|
||||||
#
|
#
|
||||||
# 2. Macros re-used in the style definitions
|
# 2. Macros re-used in the style definitions
|
||||||
@ -80,4 +83,6 @@ CiteFormat default
|
|||||||
cite %!open%{%dialog%[[#ID]][[%!makecite%]]}%!textafter%%!close%
|
cite %!open%{%dialog%[[#ID]][[%!makecite%]]}%!textafter%%!close%
|
||||||
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
||||||
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
||||||
|
# Output only the key
|
||||||
|
keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
|
||||||
End
|
End
|
||||||
|
@ -48,6 +48,8 @@ MaxCiteNames 3
|
|||||||
#
|
#
|
||||||
# Note further:
|
# Note further:
|
||||||
#
|
#
|
||||||
|
# * The LyXName "keyonly" has a special meaning: only the citation key,
|
||||||
|
# without any latex command, is output.
|
||||||
# * Capitalization indicates that the command also has a capitalized
|
# * Capitalization indicates that the command also has a capitalized
|
||||||
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
||||||
# name prefixes (von Goethe => Von Goethe).
|
# name prefixes (von Goethe => Von Goethe).
|
||||||
@ -88,6 +90,7 @@ CiteEngine authoryear
|
|||||||
fullcite[][]
|
fullcite[][]
|
||||||
footfullcite[][]
|
footfullcite[][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteEngine numerical
|
CiteEngine numerical
|
||||||
@ -103,6 +106,7 @@ CiteEngine numerical
|
|||||||
fullcite[][]
|
fullcite[][]
|
||||||
footfullcite[][]
|
footfullcite[][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +130,8 @@ CiteFormat default
|
|||||||
#
|
#
|
||||||
_notcited not cited
|
_notcited not cited
|
||||||
_addtobib Add to bibliography only.
|
_addtobib Add to bibliography only.
|
||||||
|
_keyonly Key only.
|
||||||
|
_key Key
|
||||||
_finaland , and
|
_finaland , and
|
||||||
_footnote Footnote
|
_footnote Footnote
|
||||||
_foot Foot
|
_foot Foot
|
||||||
@ -221,6 +227,8 @@ CiteFormat default
|
|||||||
footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
||||||
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
||||||
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
||||||
|
# Output only the key
|
||||||
|
keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteFormat authoryear
|
CiteFormat authoryear
|
||||||
|
@ -44,6 +44,8 @@ MaxCiteNames 3
|
|||||||
#
|
#
|
||||||
# Note further:
|
# Note further:
|
||||||
#
|
#
|
||||||
|
# * The LyXName "keyonly" has a special meaning: only the citation key,
|
||||||
|
# without any latex command, is output.
|
||||||
# * Capitalization indicates that the command also has a capitalized
|
# * Capitalization indicates that the command also has a capitalized
|
||||||
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
||||||
# name prefixes (von Goethe => Von Goethe).
|
# name prefixes (von Goethe => Von Goethe).
|
||||||
@ -80,6 +82,7 @@ CiteEngine authoryear
|
|||||||
fullcite[][]
|
fullcite[][]
|
||||||
footfullcite[][]
|
footfullcite[][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteEngine numerical
|
CiteEngine numerical
|
||||||
@ -94,6 +97,7 @@ CiteEngine numerical
|
|||||||
fullcite[][]
|
fullcite[][]
|
||||||
footfullcite[][]
|
footfullcite[][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
@ -117,6 +121,8 @@ CiteFormat default
|
|||||||
#
|
#
|
||||||
_notcited not cited
|
_notcited not cited
|
||||||
_addtobib Add to bibliography only.
|
_addtobib Add to bibliography only.
|
||||||
|
_keyonly Key only.
|
||||||
|
_key Key
|
||||||
_footnote Footnote
|
_footnote Footnote
|
||||||
_foot Foot
|
_foot Foot
|
||||||
_fullcite bibliography entry
|
_fullcite bibliography entry
|
||||||
@ -209,6 +215,8 @@ CiteFormat default
|
|||||||
footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
||||||
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
||||||
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
||||||
|
# Output only the key
|
||||||
|
keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteFormat authoryear
|
CiteFormat authoryear
|
||||||
|
@ -43,6 +43,8 @@ MaxCiteNames 3
|
|||||||
#
|
#
|
||||||
# Note further:
|
# Note further:
|
||||||
#
|
#
|
||||||
|
# * The LyXName "keyonly" has a special meaning: only the citation key,
|
||||||
|
# without any latex command, is output.
|
||||||
# * Capitalization indicates that the command also has a capitalized
|
# * Capitalization indicates that the command also has a capitalized
|
||||||
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
||||||
# name prefixes (von Goethe => Von Goethe).
|
# name prefixes (von Goethe => Von Goethe).
|
||||||
@ -93,6 +95,7 @@ CiteEngine authoryear
|
|||||||
citeyearpar [][]
|
citeyearpar [][]
|
||||||
fullcite [][]
|
fullcite [][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -112,6 +115,8 @@ CiteFormat authoryear
|
|||||||
#
|
#
|
||||||
_notcited not cited
|
_notcited not cited
|
||||||
_addtobib Add to bibliography only.
|
_addtobib Add to bibliography only.
|
||||||
|
_keyonly Key only.
|
||||||
|
_key Key
|
||||||
_fullcite bibliography entry
|
_fullcite bibliography entry
|
||||||
_bibentry Bibliography entry.
|
_bibentry Bibliography entry.
|
||||||
_before before
|
_before before
|
||||||
@ -225,4 +230,6 @@ CiteFormat authoryear
|
|||||||
fullcite {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
fullcite {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
|
||||||
# "Add to bibliography only." (dialog) / "Key; Key ... (not cited)" (button)
|
# "Add to bibliography only." (dialog) / "Key; Key ... (not cited)" (button)
|
||||||
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
||||||
|
# Output only the key
|
||||||
|
keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
|
||||||
End
|
End
|
||||||
|
@ -44,6 +44,8 @@ MaxCiteNames 2
|
|||||||
#
|
#
|
||||||
# Note further:
|
# Note further:
|
||||||
#
|
#
|
||||||
|
# * The LyXName "keyonly" has a special meaning: only the citation key,
|
||||||
|
# without any latex command, is output.
|
||||||
# * Capitalization indicates that the command also has a capitalized
|
# * Capitalization indicates that the command also has a capitalized
|
||||||
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
# form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
|
||||||
# name prefixes (von Goethe => Von Goethe).
|
# name prefixes (von Goethe => Von Goethe).
|
||||||
@ -75,6 +77,7 @@ CiteEngine authoryear
|
|||||||
citeyear[]
|
citeyear[]
|
||||||
citeyearpar[][]
|
citeyearpar[][]
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteEngine numerical
|
CiteEngine numerical
|
||||||
@ -86,6 +89,7 @@ CiteEngine numerical
|
|||||||
citeyearpar[][]
|
citeyearpar[][]
|
||||||
citeyear
|
citeyear
|
||||||
nocite
|
nocite
|
||||||
|
keyonly
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
@ -109,6 +113,8 @@ CiteFormat default
|
|||||||
#
|
#
|
||||||
_notcited not cited
|
_notcited not cited
|
||||||
_addtobib Add to bibliography only.
|
_addtobib Add to bibliography only.
|
||||||
|
_keyonly Key only.
|
||||||
|
_key Key
|
||||||
# The following are handled by BiblioInfo
|
# The following are handled by BiblioInfo
|
||||||
_etal et al.
|
_etal et al.
|
||||||
_namesep , [[separate author names in citation, except for last name]]
|
_namesep , [[separate author names in citation, except for last name]]
|
||||||
@ -155,6 +161,8 @@ CiteFormat default
|
|||||||
citeyearpar %!open%%!textbefore%%!startlink%%!year%%!endlink%%!nextyear%%!textafter%%!close%
|
citeyearpar %!open%%!textbefore%%!startlink%%!year%%!endlink%%!nextyear%%!textafter%%!close%
|
||||||
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
# "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
|
||||||
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
|
||||||
|
# Output only the key
|
||||||
|
keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
|
||||||
End
|
End
|
||||||
|
|
||||||
CiteFormat authoryear
|
CiteFormat authoryear
|
||||||
|
@ -1369,6 +1369,37 @@ def revert_biblatex(document):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def revert_citekeyonly(document):
|
||||||
|
" Revert keyonly cite command to ERT "
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while (True):
|
||||||
|
i = find_token(document.body, "\\begin_inset CommandInset citation", i)
|
||||||
|
if i == -1:
|
||||||
|
break
|
||||||
|
j = find_end_of_inset(document.body, i)
|
||||||
|
if j == -1:
|
||||||
|
document.warning("Can't find end of citation inset at line %d!!" %(i))
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
k = find_token(document.body, "LatexCommand", i, j)
|
||||||
|
if k == -1:
|
||||||
|
document.warning("Can't find LatexCommand for citation inset at line %d!" %(i))
|
||||||
|
i = j + 1
|
||||||
|
continue
|
||||||
|
cmd = get_value(document.body, "LatexCommand", k)
|
||||||
|
if cmd != "keyonly":
|
||||||
|
i = j + 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
key = get_quoted_value(document.body, "key", i, j)
|
||||||
|
if not key:
|
||||||
|
document.warning("Citation inset at line %d does not have a key!" %(i))
|
||||||
|
# Replace known new commands with ERT
|
||||||
|
document.body[i:j+1] = put_cmd_in_ert([key])
|
||||||
|
i = j + 1
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -1394,10 +1425,12 @@ convert = [
|
|||||||
[525, []],
|
[525, []],
|
||||||
[526, []],
|
[526, []],
|
||||||
[527, []],
|
[527, []],
|
||||||
[528, []]
|
[528, []],
|
||||||
|
[529, []]
|
||||||
]
|
]
|
||||||
|
|
||||||
revert = [
|
revert = [
|
||||||
|
[528, [revert_citekeyonly]],
|
||||||
[527, [revert_biblatex]],
|
[527, [revert_biblatex]],
|
||||||
[526, [revert_noprefix]],
|
[526, [revert_noprefix]],
|
||||||
[525, [revert_plural_refs]],
|
[525, [revert_plural_refs]],
|
||||||
|
@ -508,9 +508,18 @@ void InsetCitation::forOutliner(docstring & os, size_t const, bool const) const
|
|||||||
// engine, e.g. \cite[]{} for the basic engine.
|
// engine, e.g. \cite[]{} for the basic engine.
|
||||||
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||||
{
|
{
|
||||||
|
BiblioInfo const & bi = buffer().masterBibInfo();
|
||||||
|
if (getCmdName() == "keyonly") {
|
||||||
|
// Special command to only return the key
|
||||||
|
if (!bi.isBibtex(getParam("key")))
|
||||||
|
// escape chars with bibitems
|
||||||
|
os << escape(cleanupWhitespace(getParam("key")));
|
||||||
|
else
|
||||||
|
os << cleanupWhitespace(getParam("key"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
vector<CitationStyle> citation_styles = buffer().params().citeStyles();
|
vector<CitationStyle> citation_styles = buffer().params().citeStyles();
|
||||||
CitationStyle cs = asValidLatexCommand(buffer().params(), getCmdName(), citation_styles);
|
CitationStyle cs = asValidLatexCommand(buffer().params(), getCmdName(), citation_styles);
|
||||||
BiblioInfo const & bi = buffer().masterBibInfo();
|
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
docstring const cite_str = from_utf8(citationStyleToString(cs, true));
|
docstring const cite_str = from_utf8(citationStyleToString(cs, true));
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
#define LYX_FORMAT_LYX 528 // spitz: biblatex
|
#define LYX_FORMAT_LYX 529 // spitz: keyonly cite type
|
||||||
#define LYX_FORMAT_TEX2LYX 528
|
#define LYX_FORMAT_TEX2LYX 529
|
||||||
|
|
||||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user