Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Abdallah Ahmed
    @xUser5000
    I'm facing an issue with typescript
    Can I post the logs here ?
    Lars Willighagen
    @larsgw
    Sure!
    Abdallah Ahmed
    @xUser5000

    joplin-plugin-bibtex@1.0.0 dist /home/xuser500/Projects/bibtex-plugin
    webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive

    Child

    ERROR in ./node_modules/@citation-js/plugin-ris/lib-mjs/spec/mixed.js
    Module not found: Error: Can't resolve './additions' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-ris/lib-mjs/spec'
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/spec/mixed.js 2:0-36 3:26-35
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/spec/index.js
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/ris.js
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/index.js
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/biblatex.js
    Module not found: Error: Can't resolve './biblatexTypes' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping'
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/biblatex.js 3:0-36 234:14-19 238:25-30
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/input/entries.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/input/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/index.js
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-bibtex/lib/mapping/biblatex.js
    Module not found: Error: Can't resolve './biblatexTypes' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-bibtex/lib/mapping'
     @ ./node_modules/@citation-js/plugin-bibtex/lib/mapping/biblatex.js 12:44-70
     @ ./node_modules/@citation-js/plugin-bibtex/lib/mapping/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib/input/entries.js
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/bibtex.js
    Module not found: Error: Can't resolve './bibtexTypes' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping'
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/bibtex.js 3:0-34 195:19-24 209:19-24
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/mapping/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/input/entries.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/input/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib-mjs/index.js
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-bibtex/lib/mapping/bibtex.js
    Module not found: Error: Can't resolve './bibtexTypes' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-bibtex/lib/mapping'
     @ ./node_modules/@citation-js/plugin-bibtex/lib/mapping/bibtex.js 12:42-66
     @ ./node_modules/@citation-js/plugin-bibtex/lib/mapping/index.js
     @ ./node_modules/@citation-js/plugin-bibtex/lib/input/entries.js
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-ris/lib-mjs/index.js
    Module not found: Error: Can't resolve './config' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-ris/lib-mjs'
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/index.js 2:0-30 51:2-8
     @ ./node_modules/citation-js/index.js
     @ ./src/util/parser.util.ts
     @ ./src/index.ts
    
    ERROR in ./node_modules/@citation-js/plugin-ris/lib-mjs/ris.js
    Module not found: Error: Can't resolve './config' in '/home/xuser500/Projects/bibtex-plugin/node_modules/@citation-js/plugin-ris/lib-mjs'
     @ ./node_modules/@citation-js/plugin-ris/lib-mjs/ris.js 2:0-30 104:29-35
     @ ./
    I'm using Webpack version 4.43.0
    {
      "name": "joplin-plugin-bibtex",
      "version": "1.0.0",
      "scripts": {
        "dist": "webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive",
        "prepare": "npm run dist",
        "update": "npm install -g generator-joplin && yo joplin --update"
      },
      "license": "MIT",
      "keywords": [
        "joplin-plugin"
      ],
      "devDependencies": {
        "@types/node": "^14.0.14",
        "chalk": "^4.1.0",
        "copy-webpack-plugin": "^6.1.0",
        "fs-extra": "^9.0.1",
        "glob": "^7.1.6",
        "on-build-webpack": "^0.1.0",
        "tar": "^6.0.5",
        "ts-loader": "^7.0.5",
        "typescript": "^3.9.3",
        "webpack": "^4.43.0",
        "webpack-cli": "^3.3.11",
        "yargs": "^16.2.0"
      }
    }
    This is my package.json file
    Whenever I run npm run dist I get the above error
    Lars Willighagen
    @larsgw
    I think you might be able to fix this by adding .js and .json to resolve.extensions in your webpack config https://stackoverflow.com/a/51256619/5095300
    Abdallah Ahmed
    @xUser5000
    I'm sorry but I don't fully understand. Here's the contents of the webpack.config.js file:
    // -----------------------------------------------------------------------------
    // This file is used to build the plugin file (.jpl) and plugin info (.json). It
    // is recommended not to edit this file as it would be overwritten when updating
    // the plugin framework. If you do make some changes, consider using an external
    // JS file and requiring it here to minimize the changes. That way when you
    // update, you can easily restore the functionality you've added.
    // -----------------------------------------------------------------------------
    
    const path = require('path');
    const crypto = require('crypto');
    const fs = require('fs-extra');
    const chalk = require('chalk');
    const CopyPlugin = require('copy-webpack-plugin');
    const WebpackOnBuildPlugin = require('on-build-webpack');
    const tar = require('tar');
    const glob = require('glob');
    const execSync = require('child_process').execSync;
    
    const rootDir = path.resolve(__dirname);
    const userConfigFilename = './plugin.config.json';
    const userConfigPath = path.resolve(rootDir, userConfigFilename);
    const distDir = path.resolve(rootDir, 'dist');
    const srcDir = path.resolve(rootDir, 'src');
    const publishDir = path.resolve(rootDir, 'publish');
    
    const userConfig = Object.assign({}, {
        extraScripts: [],
    }, fs.pathExistsSync(userConfigPath) ? require(userConfigFilename) : {});
    
    const manifestPath = `${srcDir}/manifest.json`;
    const packageJsonPath = `${rootDir}/package.json`;
    const manifest = readManifest(manifestPath);
    const pluginArchiveFilePath = path.resolve(publishDir, `${manifest.id}.jpl`);
    const pluginInfoFilePath = path.resolve(publishDir, `${manifest.id}.json`);
    
    function validatePackageJson() {
        const content = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
        if (!content.name || content.name.indexOf('joplin-plugin-') !== 0) {
            console.warn(chalk.yellow(`WARNING: To publish the plugin, the package name should start with "joplin-plugin-" (found "${content.name}") in ${packageJsonPath}`));
        }
    
        if (!content.keywords || content.keywords.indexOf('joplin-plugin') < 0) {
            console.warn(chalk.yellow(`WARNING: To publish the plugin, the package keywords should include "joplin-plugin" (found "${JSON.stringify(content.keywords)}") in ${packageJsonPath}`));
        }
    
        if (content.scripts && content.scripts.postinstall) {
            console.warn(chalk.yellow(`WARNING: package.json contains a "postinstall" script. It is recommended to use a "prepare" script instead so that it is executed before publish. In ${packageJsonPath}`));
        }
    }
    
    function fileSha256(filePath) {
        const content = fs.readFileSync(filePath);
        return crypto.createHash('sha256').update(content).digest('hex');
    }
    
    function currentGitInfo() {
        try {
            let branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' }).toString().trim();
            const commit = execSync('git rev-parse HEAD', { stdio: 'pipe' }).toString().trim();
            if (branch === 'HEAD') branch = 'master';
            return `${branch}:${commit}`;
        } catch (error) {
            const messages = error.message ? error.message.split('\n') : [''];
            console.info(chalk.cyan('Could not get git commit (not a git repo?):', messages[0].trim()));
            console.info(chalk.cyan('Git information will not be stored in plugin info file'));
            return '';
        }
    }
    
    function readManifest(manifestPath) {
        const content = fs.readFileSync(manifestPath, 'utf8');
        const output = JSON.parse(content);
        if (!output.id) throw new Error(`Manifest plugin ID is not set in ${manifestPath}`);
        return output;
    }
    
    function createPluginArchive(sourceDir, destPath) {
        const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
            .map(f => f.substr(sourceDir.length + 1));
    
        if (!distFiles.length) throw new Error('Plugin archive was not created because the "dist" directory is empty');
        fs.removeSync(destPath);
    
        tar.create(
            {
                strict: true,
                portable: true,
                file: destPath,
                cwd: sourceDir,
                sync: true,
            },
            distFiles
        );
    
        console.info(chalk.cyan(`Plugin archive has been created in ${destPath}`));
    }
    
    function createPl
    Where to put the modifications ?
    I'm not entirely familiar with webpack or how joplin sets it up though.
    Lars Willighagen
    @larsgw
    And I now see the message at the top saying you're not supposed to edit that config, I don't know where you should change it then. If it helps, the problem seems to be that Citation.js imports JSON files without specifying the file extensions, and for webpack to allow that it needs the .json file extension added in the configuration. I could also change Citation.js to import JSON files with a file extension, but that would be in the next release.
    Abdallah Ahmed
    @xUser5000
    OK, Thanks a lot
    Abdallah Ahmed
    @xUser5000
    I got to work finally, thank you so much
    One other thing, could you please provide documentation for Errors?
    I cannot find anything related to Errors in the documentation
    Lars Willighagen
    @larsgw
    Which errors do you mean?
    Or just in general?
    Abdallah Ahmed
    @xUser5000
    In general
    Abdallah Ahmed
    @xUser5000
    So ?
    Lars Willighagen
    @larsgw
    I'm sorry, I don't have a list of all the possible errors that any function in Citation.js could throw. Specific methods may have documentation that lists the errors it might throw over at https://citation.js.org/api/0.5/, and I am happy to explain any error you might get. But I can't list all errors right now.
    Abdallah Ahmed
    @xUser5000
    OK, no problem.
    Ethan Brooks
    @ethanabrooks
    Hi I am trying to use citation.js to convert a .bib file into an array of string MLA citations.
    I am able to convert a single string bibtex entry into a string MLA citation as follows
    let Cite = require('citation-js@0.4.0-8')
    
    new Cite(`@InProceedings{pmlr-v139-brooks21a,
      title =      {Reinforcement Learning of Implicit and Explicit Control Flow Instructions},
      author =       {Brooks, Ethan and Rajendran, Janarthanan and Lewis, Richard L and Singh, Satinder},
      booktitle =      {Proceedings of the 38th International Conference on Machine Learning},
      pages =      {1082--1091},
      year =      {2021},
      editor =      {Meila, Marina and Zhang, Tong},
      volume =      {139},
      series =      {Proceedings of Machine Learning Research},
      month =      {18--24 Jul},
      publisher =    {PMLR},
      pdf =      {http://proceedings.mlr.press/v139/brooks21a/brooks21a.pdf},
      url =      {https://proceedings.mlr.press/v139/brooks21a.html},
      abstract =      {Learning to flexibly follow task instructions in dynamic environments poses interesting challenges for reinforcement learning agents. We focus here on the problem of learning control flow that deviates from a strict step-by-step execution of instructions{—}that is, control flow that may skip forward over parts of the instructions or return backward to previously completed or skipped steps. Demand for such flexible control arises in two fundamental ways: explicitly when control is specified in the instructions themselves (such as conditional branching and looping) and implicitly when stochastic environment dynamics require re-completion of instructions whose effects have been perturbed, or opportunistic skipping of instructions whose effects are already present. We formulate an attention-based architecture that meets these challenges by learning, from task reward only, to flexibly attend to and condition behavior on an internal encoding of the instructions. We test the architecture’s ability to learn both explicit and implicit control in two illustrative domains—one inspired by Minecraft and the other by StarCraft—and show that the architecture exhibits zero-shot generalization to novel instructions of length greater than those in a training set, at a performance level unmatched by three baseline recurrent architectures and one ablation architecture.}
    }`).format('bibliography', {
      template: 'citation-mla',
      lang: 'en-US'
    })
    What is the recommended method for pulling in an entire .bib file and mapping it to an array of strings?
    Lars Willighagen
    @larsgw
    I'm on mobile right now but something like this should work:
    Array.from(new Cite(`...`)).map(entry => (new Cite(entry)).format (...))
    Ethan Brooks
    @ethanabrooks
    Beautiful. That works.
    Lars Willighagen
    @larsgw
    Great!
    Antoine Cordelois
    @Billybobbonnet
    Hi all! First, thank you for the good work!
    I noticed that creating citation automatically wraps them into parentheses. I couldn't find a way to remove them except for an ugly slice.
     citation: new Citation(item)
                  .format('citation', {
                    format: 'text',
                    template: 'apa',
                    lang: 'en-US',
                  })
        // To remove the parentheses
                  // TODO come up with a better way
                  .slice(1, -1),
    If they can not be removed, how is it supposed to be handled for multiple citations?
    Egon Willighagen
    @egonw
    I don't expect the author will be online today, but I'll make sure he gets your message
    Antoine Cordelois
    @Billybobbonnet
    Thanks!
    Also, since we're at it, is there some place where I can find CSL templates (assuming I understood correctly) to extend the styles available (besides APA, harvard and Vancouver?)
    Egon Willighagen
    @egonw
    Antoine Cordelois
    @Billybobbonnet

    you mean this? https://github.com/citation-style-language/styles

    exactly! Thank you very much <3

    Lars Willighagen
    @larsgw
    @Billybobbonnet Hi, there's no option to do that in citeproc-js (which Citation.js uses under the hood for this). You might be able to achieve what you want by changing the CSL template/style though
    Antoine Cordelois
    @Billybobbonnet
    @larsgw Hi, thanks for the answer.
    Lars Willighagen
    @larsgw
    If you'd like help with that, let me know. I think it's relatively easy to remove the parentheses there but I don't think it's possible to e.g. return an array for multiple citations, so it depends a bit on what you want do to with multiple citations (you mean multiple citations in a single cluster right?).
    6 replies
    Antoine Cordelois
    @Billybobbonnet
    Hi all! Somehow I can't get the journal name to appear when I format a citation from a JS object. My initial attempt with with an attribute journal, then after looking into the CSL JSON input I replaced it with 'container-title': but I still miss the journal info.
    The code looks like this
    const data = {
      title: 'test',
     'container-title':
            'My journal title',
          volume: document.issueIndex,
          DOI: document.doi || false,
          accessed: {
            'date-parts': [new Date().toISOString()],
          },
          issued: {
            'date-parts': [date],
          },
          month: new Date(document.createdAt).toLocaleString('en-US', {
            month: 'short',
          }),
       //... other attributes
          year: new Date(document.createdAt).getFullYear(),
    }
       const obj = new Citation(data).format('bibliography', {
                format: 'text',
                template: style,
                lang: 'en-US',
              })
    Any tips on what is missing there?
    Antoine Cordelois
    @Billybobbonnet
    Nevermind I found the issue: I can't import form CSL JSON but from bibJSON. In short, I needed to name the journal as follow: "journal": {"name": "Journal of Cheminformatics"},
    Lars Willighagen
    @larsgw
    You can import from CSL-JSON, I'm not sure why the journal name wouldn't show up
    It looks like you're missing the entry type (article-journal, book, etc.) so if that field isn't one of the "other attribtues" and the style is not APA, I that might be the reason the formatted citation doesn't show it
    Antoine Cordelois
    @Billybobbonnet
    Hi @larsgw ! I skipped the entry type in this excerpt but I had it set to article-journal. The styleid a value from an iteration on ['apa', 'vanvouver', 'harvard1'] The lower case "apa" seem to be necessary.