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

Customize the rendering of inline references #27

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

xUser5000
Copy link
Contributor

This PR is not complete yet

What's done

Render all inline references that match the pattern [-@citekey] like (year)

What's left

Include all the other patterns described here

@xUser5000
Copy link
Contributor Author

Now it works on two patterns:

  • [-@dijkstraNoteTwoProblems1959]
  • [@dijkstraNoteTwoProblems1959]

case GET_REFERENCE_BY_ID:
console.log(req);
const id = req["id"];
let ans: any;
Copy link
Member

@laurent22 laurent22 Aug 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't be "any" especially since you have defined a type for the references.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

@laurent22
Copy link
Member

Did you manage to solve your issues? If not, please let me know and describe in details what the issue is.

@xUser5000
Copy link
Contributor Author

What has been done so far

  • Collect all references in a note (by searching for any word that matches the pattern "@citekey") to be included in the note footer
  • Render the following patterns into the corresponding format:
    • [-@citekey] gets rendered as (year)
    • [@citekey] gets rendered as (author year)

Issues encountered

I want to execute some javascript code during the rendering of every reference. For some reason, just writing a <script> tag and putting the code inside it does not work. The only way I found to get it working was by doing sth like this: <style onload='${script.replace(/\n/g, " ")}' />, where the variable script is a string containing the desired JS code. This works but the downside is that, for some reason, whenever the style tag gets added to the note, everything after it just disappears from the document. For example, if the document contains the following:

<span class="hello">Hello Worl</span>
<style> .hello { font-weight: bold } </style>
This is just a sample text

The rendered content looks like this:
Hello World

What's left to do

Implement the remaining patterns described here

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

Successfully merging this pull request may close these issues.

2 participants