Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Bulleted Argument #41

Closed
trinker opened this issue Jun 6, 2013 · 4 comments
Closed

Request Bulleted Argument #41

trinker opened this issue Jun 6, 2013 · 4 comments

Comments

@trinker
Copy link
Contributor

trinker commented Jun 6, 2013

In some HTML5 formats the bulleted list output doesn't look as good (reveal.js). I'm proposing a bulleted argument that might operate like this (changes to bibligraphy and print_html:

bibliography <-
function (style = "markdown", .bibstyle = "JSS", ordering = c("authors", 
    "year", "title", "journal", "volume", "number", "pages", 
    "doi", "url"), sort = FALSE, bibtex = get("bibtex_data", 
    envir = knitcitations_options),  bulleted = TRUE, ...) 
{
    out <- read_cache(bibtex = bibtex)
    if (length(out) > 0) {
        if (sort) {
            ordering <- sort(names(out))
            out <- out[ordering]
        }
    }
    if (style %in% c("R", "text", "bibtex", "textVersion", "citation", 
        "LaTeX")) {
        output <- print(out, style, .bibstyle = .bibstyle, ...)
    }
    else if (style == "rdfa") {
        output <- print_rdfa(out, ordering = ordering)
        names(output) = ""
        output <- paste(unlist(output), collapse = "", sep = "")
        pretty_output <- cat(output)
    }
    else if (style == "html") {
        output <- print_html(out, ordering = ordering, bulleted = bulleted)
        names(output) = ""
        pretty_output <- cat(output)
    }
    else if (style == "markdown") {
        output <- print_markdown(out, ordering = ordering)
        names(output) = ""
        pretty_output <- cat(output)
    }
    else {
        stop("Style not recognized")
    }
    invisible(output)
}

print_html <- 
function (bib, ordering = c("authors", "year", "title", "journal", 
    "volume", "number", "pages", "doi", "uri"), bulleted = TRUE) 
{
    references <- sapply(bib, function(r) {
        title <- paste(r$title, ".", sep = "")
        authors <- paste(sapply(r$author, function(x) paste(x$given[1], 
            " ", x$family, ", ", collapse = "", sep = "")), sep = "", 
            collapse = "")
        authors <- paste(" ", authors, sep = "")
        year <- if (!is.null(r$year)) 
            paste(" (", r$year, ")", sep = "")
        journal <- if (!is.null(r$journal)) 
            paste(" <em>", r$journal, "</em>", sep = "")
        volume <- if (!is.null(r$volume)) 
            paste(" <strong>", r$volume, "</strong>", sep = "")
        number <- if (!is.null(r$number)) 
            paste(" (", r$number, ") ", sep = "")
        pgs <- if (!is.null(r$pages)) 
            strsplit(r$pages, "--")[[1]]
        spage <- if (!is.null(pgs[1])) 
            paste(" ", pgs[1], sep = "")
        epage <- if (!is.null(pgs[2])) 
            paste("-", pgs[2], sep = "")
        pages <- paste(spage, epage, sep = "")
        doi <- if (!is.null(r$doi)) 
            paste(" <a href=\"http://dx.doi.org/", r$doi, "\">", 
                r$doi, "</a>", sep = "")
        uri <- if (is.null(r$doi) && !is.null(r$url)) 
            paste(" <a href=\"", r$url, "\">", r$url, "</a>", 
                sep = "")
        bibline <- bib_format(ordering, authors, year, title, 
            journal, volume, number, pages, doi, uri, collapse = " ")
        if (bulleted) {
            paste("\n-", bibline, sep = "")
        } else {
            paste("<p>", bibline, "</p>", sep = "")
        }
    })
    paste(paste(references, collapse = "", sep = ""))
}

Then the indenting can be handled via css class like the following:

.refs {
  padding-left: 80px;
  text-indent: -35px;
}

by the user.

@cboettig
Copy link
Owner

cboettig commented Jun 6, 2013

beautiful. I can just paste this in of course, but perhaps you'd like to
send this as a pull request?

On Thu, Jun 6, 2013 at 5:25 AM, Tyler Rinker notifications@github.comwrote:

In some HTML5 formats the bulleted list output doesn't look as good
(reveal.js). I'm proposing a bulleted argument that might operate like
this (changes to bibligraphy and print_html:

bibliography <-
function (style = "markdown", .bibstyle = "JSS", ordering = c("authors",
"year", "title", "journal", "volume", "number", "pages",
"doi", "url"), sort = FALSE, bibtex = get("bibtex_data",
envir = knitcitations_options), bulleted = TRUE, ...)
{
out <- read_cache(bibtex = bibtex)
if (length(out) > 0) {
if (sort) {
ordering <- sort(names(out))
out <- out[ordering]
}
}
if (style %in% c("R", "text", "bibtex", "textVersion", "citation",
"LaTeX")) {
output <- print(out, style, .bibstyle = .bibstyle, ...)
}
else if (style == "rdfa") {
output <- print_rdfa(out, ordering = ordering)
names(output) = ""
output <- paste(unlist(output), collapse = "", sep = "")
pretty_output <- cat(output)
}
else if (style == "html") {
output <- print_html(out, ordering = ordering, bulleted = bulleted)
names(output) = ""
pretty_output <- cat(output)
}
else if (style == "markdown") {
output <- print_markdown(out, ordering = ordering)
names(output) = ""
pretty_output <- cat(output)
}
else {
stop("Style not recognized")
}
invisible(output)
}

print_html <-
function (bib, ordering = c("authors", "year", "title", "journal",
"volume", "number", "pages", "doi", "uri"), bulleted = TRUE)
{
references <- sapply(bib, function(r) {
title <- paste(r$title, ".", sep = "")
authors <- paste(sapply(r$author, function(x) paste(x$given[1],
" ", x$family, ", ", collapse = "", sep = "")), sep = "",
collapse = "")
authors <- paste(" ", authors, sep = "")
year <- if (!is.null(r$year))
paste(" (", r$year, ")", sep = "")
journal <- if (!is.null(r$journal))
paste(" ", r$journal, "", sep = "")
volume <- if (!is.null(r$volume))
paste(" ", r$volume, "", sep = "")
number <- if (!is.null(r$number))
paste(" (", r$number, ") ", sep = "")
pgs <- if (!is.null(r$pages))
strsplit(r$pages, "--")[[1]]
spage <- if (!is.null(pgs[1]))
paste(" ", pgs[1], sep = "")
epage <- if (!is.null(pgs[2]))
paste("-", pgs[2], sep = "")
pages <- paste(spage, epage, sep = "")
doi <- if (!is.null(r$doi))
paste(" <a href="http://dx.doi.org/", r$doi, "">",
r$doi, "", sep = "")
uri <- if (is.null(r$doi) && !is.null(r$url))
paste(" <a href="", r$url, "">", r$url, "",
sep = "")
bibline <- bib_format(ordering, authors, year, title,
journal, volume, number, pages, doi, uri, collapse = " ")
if (bulleted) {
paste("\n-", bibline, sep = "")
} else {
paste("

", bibline, "

", sep = "")
}
})
paste(paste(references, collapse = "", sep = ""))
}

Then the indenting can be handled via css class like the following:

``
.refs {
padding-left: 80px;
text-indent: -35px;
}

by the user.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41
.

Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/

@trinker
Copy link
Contributor Author

trinker commented Jun 6, 2013

If that's easier for you but I don't care either way. Just wanted to see
the functionality.

On Thu, Jun 6, 2013 at 11:07 AM, Carl Boettiger notifications@github.comwrote:

beautiful. I can just paste this in of course, but perhaps you'd like to
send this as a pull request?

On Thu, Jun 6, 2013 at 5:25 AM, Tyler Rinker notifications@github.comwrote:

In some HTML5 formats the bulleted list output doesn't look as good
(reveal.js). I'm proposing a bulleted argument that might operate like
this (changes to bibligraphy and print_html:

bibliography <-
function (style = "markdown", .bibstyle = "JSS", ordering = c("authors",
"year", "title", "journal", "volume", "number", "pages",
"doi", "url"), sort = FALSE, bibtex = get("bibtex_data",
envir = knitcitations_options), bulleted = TRUE, ...)
{
out <- read_cache(bibtex = bibtex)
if (length(out) > 0) {
if (sort) {
ordering <- sort(names(out))
out <- out[ordering]
}
}
if (style %in% c("R", "text", "bibtex", "textVersion", "citation",
"LaTeX")) {
output <- print(out, style, .bibstyle = .bibstyle, ...)
}
else if (style == "rdfa") {
output <- print_rdfa(out, ordering = ordering)
names(output) = ""
output <- paste(unlist(output), collapse = "", sep = "")
pretty_output <- cat(output)
}
else if (style == "html") {
output <- print_html(out, ordering = ordering, bulleted = bulleted)
names(output) = ""
pretty_output <- cat(output)
}
else if (style == "markdown") {
output <- print_markdown(out, ordering = ordering)
names(output) = ""
pretty_output <- cat(output)
}
else {
stop("Style not recognized")
}
invisible(output)
}

print_html <-
function (bib, ordering = c("authors", "year", "title", "journal",
"volume", "number", "pages", "doi", "uri"), bulleted = TRUE)
{
references <- sapply(bib, function(r) {
title <- paste(r$title, ".", sep = "")
authors <- paste(sapply(r$author, function(x) paste(x$given[1],
" ", x$family, ", ", collapse = "", sep = "")), sep = "",
collapse = "")
authors <- paste(" ", authors, sep = "")
year <- if (!is.null(r$year))
paste(" (", r$year, ")", sep = "")
journal <- if (!is.null(r$journal))
paste(" ", r$journal, "", sep = "")
volume <- if (!is.null(r$volume))
paste(" ", r$volume, "", sep = "")
number <- if (!is.null(r$number))
paste(" (", r$number, ") ", sep = "")
pgs <- if (!is.null(r$pages))
strsplit(r$pages, "--")[[1]]
spage <- if (!is.null(pgs[1]))
paste(" ", pgs[1], sep = "")
epage <- if (!is.null(pgs[2]))
paste("-", pgs[2], sep = "")
pages <- paste(spage, epage, sep = "")
doi <- if (!is.null(r$doi))
paste(" <a href="http://dx.doi.org/", r$doi, "">",
r$doi, "", sep = "")
uri <- if (is.null(r$doi) && !is.null(r$url))
paste(" <a href="", r$url, "">", r$url, "",
sep = "")
bibline <- bib_format(ordering, authors, year, title,
journal, volume, number, pages, doi, uri, collapse = " ")
if (bulleted) {
paste("\n-", bibline, sep = "")
} else {
paste("

", bibline, "

", sep = "")
}
})
paste(paste(references, collapse = "", sep = ""))
}

Then the indenting can be handled via css class like the following:

``
.refs {
padding-left: 80px;
text-indent: -35px;
}

by the user.


Reply to this email directly or view it on GitHub<
https://github.com/cboettig/knitcitations/issues/41>
.

Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-19051598
.

@cboettig
Copy link
Owner

cboettig commented Jun 6, 2013

a pull request that passes R CMD CHECK with updated roxygen documentation
including a bulleted example would be great...

On Thu, Jun 6, 2013 at 8:39 AM, Tyler Rinker notifications@github.comwrote:

If that's easier for you but I don't care either way. Just wanted to see
the functionality.

On Thu, Jun 6, 2013 at 11:07 AM, Carl Boettiger notifications@github.comwrote:

beautiful. I can just paste this in of course, but perhaps you'd like to
send this as a pull request?

On Thu, Jun 6, 2013 at 5:25 AM, Tyler Rinker notifications@github.comwrote:

In some HTML5 formats the bulleted list output doesn't look as good
(reveal.js). I'm proposing a bulleted argument that might operate like
this (changes to bibligraphy and print_html:

bibliography <-
function (style = "markdown", .bibstyle = "JSS", ordering =
c("authors",
"year", "title", "journal", "volume", "number", "pages",
"doi", "url"), sort = FALSE, bibtex = get("bibtex_data",
envir = knitcitations_options), bulleted = TRUE, ...)
{
out <- read_cache(bibtex = bibtex)
if (length(out) > 0) {
if (sort) {
ordering <- sort(names(out))
out <- out[ordering]
}
}
if (style %in% c("R", "text", "bibtex", "textVersion", "citation",
"LaTeX")) {
output <- print(out, style, .bibstyle = .bibstyle, ...)
}
else if (style == "rdfa") {
output <- print_rdfa(out, ordering = ordering)
names(output) = ""
output <- paste(unlist(output), collapse = "", sep = "")
pretty_output <- cat(output)
}
else if (style == "html") {
output <- print_html(out, ordering = ordering, bulleted = bulleted)
names(output) = ""
pretty_output <- cat(output)
}
else if (style == "markdown") {
output <- print_markdown(out, ordering = ordering)
names(output) = ""
pretty_output <- cat(output)
}
else {
stop("Style not recognized")
}
invisible(output)
}

print_html <-
function (bib, ordering = c("authors", "year", "title", "journal",
"volume", "number", "pages", "doi", "uri"), bulleted = TRUE)
{
references <- sapply(bib, function(r) {
title <- paste(r$title, ".", sep = "")
authors <- paste(sapply(r$author, function(x) paste(x$given[1],
" ", x$family, ", ", collapse = "", sep = "")), sep = "",
collapse = "")
authors <- paste(" ", authors, sep = "")
year <- if (!is.null(r$year))
paste(" (", r$year, ")", sep = "")
journal <- if (!is.null(r$journal))
paste(" ", r$journal, "", sep = "")
volume <- if (!is.null(r$volume))
paste(" ", r$volume, "", sep = "")
number <- if (!is.null(r$number))
paste(" (", r$number, ") ", sep = "")
pgs <- if (!is.null(r$pages))
strsplit(r$pages, "--")[[1]]
spage <- if (!is.null(pgs[1]))
paste(" ", pgs[1], sep = "")
epage <- if (!is.null(pgs[2]))
paste("-", pgs[2], sep = "")
pages <- paste(spage, epage, sep = "")
doi <- if (!is.null(r$doi))
paste(" <a href="http://dx.doi.org/", r$doi, "">",
r$doi, "", sep = "")
uri <- if (is.null(r$doi) && !is.null(r$url))
paste(" <a href="", r$url, "">", r$url, "",
sep = "")
bibline <- bib_format(ordering, authors, year, title,
journal, volume, number, pages, doi, uri, collapse = " ")
if (bulleted) {
paste("\n-", bibline, sep = "")
} else {
paste("

", bibline, "

", sep = "")
}
})
paste(paste(references, collapse = "", sep = ""))
}

Then the indenting can be handled via css class like the following:

``
.refs {
padding-left: 80px;
text-indent: -35px;
}

by the user.


Reply to this email directly or view it on GitHub<
https://github.com/cboettig/knitcitations/issues/41>
.

Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/


Reply to this email directly or view it on GitHub<
https://github.com/cboettig/knitcitations/issues/41#issuecomment-19051598>

.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-19053981
.

Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/

@cboettig
Copy link
Owner

cboettig commented Jun 7, 2013

Closed by pull request #42

@cboettig cboettig closed this as completed Jun 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants