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

Fix Bibtex rendering in reports #1001

Merged
merged 24 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50d4743
Change @software for @misc
eurunuela Nov 22, 2023
ce0c976
Added function to convert bibtex to html
eurunuela Nov 22, 2023
a0e048e
Created new reports dependencies with APA for bibtex
eurunuela Nov 22, 2023
61b2d2b
Undo changes in pyproject.toml
eurunuela Nov 22, 2023
bfb7bdb
Add pybtex as a dependency
eurunuela Nov 22, 2023
5f1cdb5
Fix style issues
martaarbizu Nov 22, 2023
f24581f
remove import
martinezeguiluz Nov 22, 2023
b0be904
Merge pull request #1 from martaarbizu/Fix-style-issues
eurunuela Nov 22, 2023
0bed4f5
Merge pull request #2 from martinezeguiluz/Fix_style
eurunuela Nov 22, 2023
3157f5f
Fix_style_issues_2
martaarbizu Nov 22, 2023
1b08143
Merge pull request #3 from martaarbizu/Fix-style-issues
eurunuela Nov 22, 2023
0668d67
Tried to fix inline citations
eurunuela Jan 25, 2024
2233788
remove breakpoint
notZaki Jan 26, 2024
8a358dc
Update citekey for Hunter2007
notZaki Jan 26, 2024
50d4fc6
Allow underscores to be in cite keys
notZaki Jan 26, 2024
5109cfc
Substitute inline citations with str.replace
notZaki Jan 26, 2024
41b9c84
Remove duplicated curly brace from bokeh reference
notZaki Jan 26, 2024
e7f6565
Remove colon from Hunter citekey
eurunuela Jan 26, 2024
171868b
Update Hunter citekey in docs
eurunuela Jan 26, 2024
461403d
Generate bibliography as list instead of lines
notZaki Jan 26, 2024
820d8cc
Accommodate authors without last/family names in bib
notZaki Jan 26, 2024
2387717
Show bibliography as list in report
notZaki Jan 26, 2024
28af810
Inherit content styles for bibliography in report
notZaki Jan 26, 2024
ead5da7
Merge pull request #4 from notZaki/bibtex_fix
eurunuela Jan 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dependencies = [
"nilearn>=0.7",
"numpy>=1.16",
"pandas>=2.0",
"pybtex",
"pybtex-apa-style",
"scikit-learn>=0.21",
"scipy>=1.2.0",
"threadpoolctl",
Expand All @@ -48,6 +50,7 @@ doc = [
"sphinx-argparse",
"sphinxcontrib-bibtex",
]

tests = [
"codecov",
"coverage",
Expand Down
19 changes: 17 additions & 2 deletions tedana/reporting/html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@
import pandas as pd
from bokeh import __version__ as bokehversion
from bokeh import embed, layouts, models
from pybtex.database.input import bibtex

from tedana import __version__
from tedana.io import load_json
from tedana.reporting import dynamic_figures as df

LGR = logging.getLogger("GENERAL")

from pybtex.plugin import find_plugin

APA = find_plugin("pybtex.style.formatting", "apa")()
HTML = find_plugin("pybtex.backends", "html")()


def _bib2html(bibliography):
parser = bibtex.Parser()
bibliography = parser.parse_file(bibliography)
formatted_bib = APA.format_bibliography(bibliography)
return "<br>".join(entry.text.render(HTML) for entry in formatted_bib)


def _generate_buttons(out_dir, io_generator):
resource_path = Path(__file__).resolve().parent.joinpath("data", "html")
Expand Down Expand Up @@ -85,6 +98,9 @@ def _update_template_bokeh(bokeh_id, info_table, about, prefix, references, boke
# Initial carpet plot (default one)
initial_carpet = f"./figures/{prefix}carpet_optcom.svg"

# Convert bibtex to html
references = _bib2html(references)

body_template_name = "report_body_template.html"
body_template_path = resource_path.joinpath(body_template_name)
with open(str(body_template_path)) as body_file:
Expand Down Expand Up @@ -273,8 +289,7 @@ def get_elbow_val(elbow_prefix):
with open(opj(io_generator.out_dir, f"{io_generator.prefix}report.txt"), "r+") as f:
about = f.read()

with open(opj(io_generator.out_dir, f"{io_generator.prefix}references.bib")) as f:
references = f.read()
references = opj(io_generator.out_dir, f"{io_generator.prefix}references.bib")

# Read info table
data_descr_path = io_generator.get_name("data description json")
Expand Down
Loading