Skip to content

Commit

Permalink
Fix formatter (#7)
Browse files Browse the repository at this point in the history
* 🐛 string formatting
  • Loading branch information
denkiwakame authored Jan 12, 2019
1 parent 4e36110 commit 16f6a0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/*
packages/*
15 changes: 8 additions & 7 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ UI = {
for (author of data.authors) {
const templateStr = require('../html/_chip.html');
const compiled = _.template(templateStr);
const chipEl = self._str2elem( compiled({ tag: author.replace(/\ /g, '_') }) );
const chipEl = self._str2elem( compiled({ tag: author.trim().replace(/\ +/g, '_') }) );
$(".mdc-chip-set").append(chipEl);
self.chipSet.addChip(chipEl);
}
Expand Down Expand Up @@ -146,11 +146,12 @@ App = {
},
getPaperInfo: function(url) {
const self = this;
// const url_ = "http://openaccess.thecvf.com/content_ECCV_2018/papers/Martin_Sundermeyer_Implicit_3D_Orientation_ECCV_2018_paper.pdf";
// self.getPDFInfo(url_);
if (self.isArxivUrl(url)) return self.getArXivInfo(url);
if (self.isPDF(url)) return self.getPDFInfo(url);
},
formatString: function(str) {
return str.trim().replace(/\n/g,' ').replace(/\ +/g, ' ');
},
getArXivInfo: function(url) {
UI.showProgressBar();
const self = this;
Expand All @@ -165,8 +166,8 @@ App = {
statusCode: {
200: (data)=> {
const $entry= $(data).find("entry");
const paperTitle = $entry.find("title")[0].textContent.replace(/\n/g,' '); // FIXME
const abst = $entry.find("summary")[0].textContent.trim().replace(/\n/g,' '); // FIXME
const paperTitle = self.formatString($entry.find("title")[0].textContent);
const abst = self.formatString($entry.find("summary")[0].textContent);
const authors = _.map($entry.find("author"), (a) => { return a.textContent.trim(); });
UI.setFormContents({
url : url,
Expand All @@ -190,8 +191,8 @@ App = {
const pdfLoading = pdfjsLib.getDocument(url);
pdfLoading.promise.then((pdf)=>{
pdf.getMetadata().then((d)=>{
const authors = d.info.Author.trim().replace("/ /_/g").split(",");
const paperTitle = d.info.Title.replace(/\n/g,' ');
const authors = d.info.Author.trim().split(",");
const paperTitle = self.formatString(d.info.Title);
UI.setFormContents({
url : url,
paperTitle : paperTitle,
Expand Down

0 comments on commit 16f6a0e

Please sign in to comment.