Skip to content

Commit

Permalink
Fixed bugs, updated news and prep for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi-1U committed Oct 15, 2024
1 parent f2c53bd commit bb77ceb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rebib
Type: Package
Title: Convert and Aggregate Bibliographies
Version: 0.3.2
Version: 0.5.0
Authors@R:
c(person(given = "Abhishek",
family = "Ulayil",
Expand Down Expand Up @@ -56,5 +56,5 @@ Suggests:
VignetteBuilder: knitr
Config/testthat/edition: 3
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Language: en-US
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# version 0.5.0

## bug fixes :

1. Fixed unresolved dependency issues in parser.
2. Fixed issue #21 where it could not read paths with spaces.
3. Fixed issue #23 to detect bibliography files outside of the article folder and refer it from the `thebibliography{...}` command.
4. Some patches to adapt the parser to parse slightly different format/style of bibliography as mentioned in issue #24.
5. Included test coverage using codecov and covr, fixing issue #13.

# version 0.3.2

## bug fixes :
Expand Down
26 changes: 13 additions & 13 deletions R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,40 @@ bibliography_parser <- function(single_bib_data) {
# if there is no new block, we can't parse the data

concat_lines <- function(single_bib_data) {
trimmed_lines <- str_trim(single_bib_data)
concatenated <- paste(str_trim(trimmed_lines), collapse = " ")
trimmed_lines <- stringr::str_trim(single_bib_data)
concatenated <- paste(stringr::str_trim(trimmed_lines), collapse = " ")
return(concatenated)
}
bib_data_str <- concat_lines(single_bib_data)

# get unique_id in \bibitem{unique_id}
bib_record$unique_id <- str_match(bib_data_str,
bib_record$unique_id <- stringr::str_match(bib_data_str,
"\\\\bibitem(?:\\[[^\\]]*\\])?\\{([^\\}]+)\\}")[2]
bib_record$unique_id <- str_trim(bib_record$unique_id)
bib_record$unique_id <- stringr::str_trim(bib_record$unique_id)

bib_record$author <- str_match(bib_data_str,
bib_record$author <- stringr::str_match(bib_data_str,
"\\}(.+)\\\\emph\\{")[2]
bib_record$author <- str_trim(bib_record$author)
bib_record$author <- stringr::str_trim(bib_record$author)
bib_record$author <- gsub("[.,]+$", "", bib_record$author)


bib_record$title <- str_match(bib_data_str,
bib_record$title <- stringr::str_match(bib_data_str,
"\\\\emph\\{([^\\}]+?)\\}")[2]
bib_record$title <- str_trim(bib_record$title)
bib_record$title <- stringr::str_trim(bib_record$title)

rest_bib_data <- str_match(bib_data_str,
rest_bib_data <- stringr::str_match(bib_data_str,
"\\\\emph\\{[^\\}]+\\}(.+)")[2]

bib_record$year <- str_match(rest_bib_data, "([0-9]{4})")[2]
rest_bib_data <- str_match(bib_data_str,
bib_record$year <- stringr::str_match(rest_bib_data, "([0-9]{4})")[2]
rest_bib_data <- stringr::str_match(bib_data_str,
"\\\\emph\\{[^\\}]+\\}(.+)")[2]

# put all the remaining data in journal
rest_bib_data <- gsub(bib_record$year, "", rest_bib_data)
rest_bib_data <- str_trim(rest_bib_data)
rest_bib_data <- stringr::str_trim(rest_bib_data)
rest_bib_data <- gsub("^[ ,.]+", "", rest_bib_data)
rest_bib_data <- gsub("[ ,.]+$", "", rest_bib_data)
bib_record$journal <- str_trim(rest_bib_data)
bib_record$journal <- stringr::str_trim(rest_bib_data)

return(bib_record)
} else{
Expand Down

0 comments on commit bb77ceb

Please sign in to comment.