Skip to content

Commit

Permalink
Remove variable wrapper
Browse files Browse the repository at this point in the history
This is a concept from citeproc.js. If necessary, we will provide
a new interface for that purpose in citeproc-java
  • Loading branch information
michel-kraemer committed Feb 2, 2021
1 parent 5cdafcf commit fbf8e3d
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 133 deletions.
3 changes: 0 additions & 3 deletions buildSrc/src/main/groovy/SourceGenerator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ class SourceGenerator {
def dst = new File(project.projectDir, 'src-gen/main/java')
dst.mkdirs()

renderTemplatesInternal('Context', dst, true)
renderTemplatesInternal('CSLType', dst, true)
renderTemplatesInternal('CSLLabel', dst, true)
renderTemplatesInternal('SecondFieldAlign', dst, true)
Expand All @@ -205,8 +204,6 @@ class SourceGenerator {
renderTemplatesInternal('Bibliography', dst)
renderTemplatesInternal('Citation', dst)

renderTemplatesInternal('VariableWrapperParams', dst)

renderParserTemplate('EndNoteParser', dst)
renderParserTemplate('RISParser', dst)
}
Expand Down
10 changes: 4 additions & 6 deletions citeproc-java/src/main/java/de/undercouch/citeproc/CSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public class CSL {
*/
public CSL(ItemDataProvider itemDataProvider, String style) throws IOException {
this(itemDataProvider, new DefaultLocaleProvider(),
new DefaultAbbreviationProvider(), null, style, "en-US");
new DefaultAbbreviationProvider(), style, "en-US");
}

/**
Expand All @@ -174,16 +174,14 @@ public CSL(ItemDataProvider itemDataProvider, String style) throws IOException {
*/
public CSL(ItemDataProvider itemDataProvider, String style, String lang) throws IOException {
this(itemDataProvider, new DefaultLocaleProvider(),
new DefaultAbbreviationProvider(), null, style, lang);
new DefaultAbbreviationProvider(), style, lang);
}

/**
* Constructs a new citation processor
* @param itemDataProvider an object that provides citation item data
* @param localeProvider an object that provides CSL locales
* @param abbreviationProvider an object that provides abbreviations
* @param variableWrapper an optional object that can affect how items
* are rendered in citations and bibliographies
* @param style the citation style to use. May either be a serialized
* XML representation of the style or a style's name such as <code>ieee</code>.
* In the latter case, the processor loads the style from the classpath (e.g.
Expand All @@ -192,8 +190,8 @@ public CSL(ItemDataProvider itemDataProvider, String style, String lang) throws
* @throws IOException if the CSL style could not be loaded
*/
public CSL(ItemDataProvider itemDataProvider, LocaleProvider localeProvider,
AbbreviationProvider abbreviationProvider, VariableWrapper variableWrapper,
String style, String lang) throws IOException {
AbbreviationProvider abbreviationProvider, String style,
String lang) throws IOException {
// load style if needed
if (!isStyle(style)) {
style = loadStyle(style);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class CSLBuilder {
private ItemDataProvider itemDataProvider;
private LocaleProvider localeProvider = new DefaultLocaleProvider();
private AbbreviationProvider abbreviationProvider = new DefaultAbbreviationProvider();
private VariableWrapper variableWrapper;
private String style;
private String lang = "en-US";

Expand Down Expand Up @@ -50,16 +49,6 @@ public CSLBuilder abbreviationProvider(AbbreviationProvider abbreviationProvider
return this;
}

/**
* Set an optional variable wrapper
* @param variableWrapper an object that decorates rendered items
* @return {@code this} builder
*/
public CSLBuilder variableWrapper(VariableWrapper variableWrapper) {
this.variableWrapper = variableWrapper;
return this;
}

/**
* Set the citation style to use. This may either be a serialized XML
* representation of the style or a style's name such as <code>ieee</code>.
Expand Down Expand Up @@ -89,7 +78,6 @@ public CSLBuilder lang(String lang) {
* @throws IOException if the CSL style could not be loaded
*/
public CSL build() throws IOException {
return new CSL(itemDataProvider, localeProvider, abbreviationProvider,
variableWrapper, style, lang);
return new CSL(itemDataProvider, localeProvider, abbreviationProvider, style, lang);
}
}

This file was deleted.

26 changes: 0 additions & 26 deletions citeproc-java/src/test/java/de/undercouch/citeproc/CSLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,32 +394,6 @@ public void abbreviations() throws Exception {
assertEquals("Johnson and Kernighan, \u201cB.\u201d", a.get(0).getText());
}

/**
* Tests if output can be decorated
* @throws Exception if something goes wrong
*/
@Test
public void variableWrapper() throws Exception {
VariableWrapper wrapper = (params, prePunct, str, postPunct) -> {
if (params.getContext() == Context.CITATION &&
Arrays.asList(params.getVariableNames()).contains("author")) {
return prePunct + "<strong>" + str + "</strong>" + postPunct;
}
return prePunct + str + postPunct;
};

CSL citeproc = new CSLBuilder()
.itemDataProvider(new ListItemDataProvider(items))
.variableWrapper(wrapper)
.style("chicago-note-bibliography")
.build();
List<Citation> a = citeproc.makeCitation(items[0].getId());
assertEquals(0, a.get(0).getIndex());
assertEquals("<strong>Johnson and Kernighan</strong>, "
+ "\u201cThe Programming Language B.\u201d",
a.get(0).getText());
}

/**
* Tests if citation items can be registered unsorted
* @throws Exception if something goes wrong
Expand Down
10 changes: 0 additions & 10 deletions citeproc-java/templates/Context.json

This file was deleted.

52 changes: 0 additions & 52 deletions citeproc-java/templates/VariableWrapperParams.json

This file was deleted.

0 comments on commit fbf8e3d

Please sign in to comment.