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

[rejour-relatex]: make footnote identification less arbitrary, like a counter or... #28

Open
github-actions bot opened this issue Feb 16, 2022 · 0 comments
Labels

Comments

@github-actions
Copy link

[rejour-relatex]: make footnote identification less arbitrary, like a counter or something

@ts-ignore

https://github.com/JournalOfTrialAndError/JOTE/blob/4b14de45df7a9618fe579a3052560971317727ef/libs/rejour/jast-util-to-texast/src/lib/handlers/xref.ts#L90

  // Maybe add a new type to texast: citation.

  // TODO: [rejour-rehype/citations] make checks for the kind of citations used.
  console.log(node.attributes)
  switch (node.attributes.refType) {
    case 'bibr': {
      return j(
        node,
        'command',
        { name: j.citationAnalyzer(node) || 'autocite' },
        [
          {
            type: 'commandArg',
            children: [
              {
                type: 'text',
                value:
                  node.attributes.rid ||
                  node.children
                    .map((node) => {
                      //@ts-ignore
                      const n = node.value.replace(/[\[\], ]/g, '')
                      return n ? `bib${n}` : undefined
                    })
                    .filter((n) => !!n)
                    .join(','),
              },
            ],
          },
        ]
      )
    }
    case 'fig': {
      return j(node, 'command', { name: 'autocite' }, [
        {
          type: 'commandArg',
          children: [
            {
              type: 'text',
              //@ts-expect-error
              value: 'bib' + node.children[0]?.value?.replace(/[\[\]]/g, ''),
            },
          ],
        },
      ])
    }
    case 'fn': {
      const fnContent = j.footnotes[
        // TODO: [rejour-relatex]: make footnote identification less arbitrary, like a counter or something
        //@ts-ignore
        parseInt(node.children?.[0]?.value?.replace(/[\[\]]/g, '')) - 1
      ] as any
      return j(node, 'command', { name: 'footnote' }, [
        {
          type: 'commandArg',
          children:
            fnContent.type === 'paragraph' ? fnContent.children : [fnContent],
        },
      ])
    }

ac31ceffe8d80dcdddfc216547383e42440ab5fa

@github-actions github-actions bot added the todo label Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants