Skip to content

[rejour-relatex] make latex cite command setting more modular and customizable #32

Open

Description

@github-actions

[rejour-relatex] make latex cite command setting more modular and customizable

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

  // TODO: [rejour-rehype/citations] make citation parsing less hardcoded
  // Maybe add a new type to texast: citation.

  const labelToText: { [key: string]: string } = {
    page: 'pp.',
    appendix: 'App.',
  }

  // TODO: [rejour-rehype/citations] make checks for the kind of citations used.
  switch (node.attributes.refType) {
    case 'bibr': {
      const customType = node.attributes.customType

      // TODO: [rejour-relatex] make latex cite command setting more modular and customizable
      let command
      let pre
      let post
      if (customType) {
        const customData = JSON.parse(customType)
        const { prefix, infix, label, locator, mode, suffix } = customData

        const pref = (mode ? infix : prefix) || ''

        const suff = `${
          label && label !== 'none'
            ? `${labelToText[label] || label || 'pp.'} `
            : ''
        }${locator || ''}`
        command = mode ? 'textcite' : 'parencite'

        if (pref) pre = pref
        if (suff) post = suff
      }

      const optCommandArgs = createOptCiteArgs(pre, post)
      return j(
        node,
        'command',
        { name: command || j.citationAnalyzer(node) || 'autocite' },
        [
          ...optCommandArgs,
          {
            type: 'commandArg',
            children: [

c0fa605e4d86bc398d0d0222c8f6f38059efad35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions