From 37e14b397ca0652b1351c6501120ac684616ae00 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 15 Dec 2020 21:56:14 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/ContentsPage/ContentsPage.vue | 4 +-- client/components/Reader/share/BookParser.js | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index a9c91ce8..e1f2d9a1 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -195,9 +195,7 @@ class ContentsPage extends Vue { const ims = parsed.images; for (i = 0; i < ims.length; i++) { const image = ims[i]; - let id = image.href; - if (id[0] == "#") - id = id.substr(1); + let {id} = parsed.imageHrefToId(image.href); const label = `Изображение ${image.num}`; const indentStyle = getIndentStyle(1); diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index 1705c007..cec2f762 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -497,6 +497,15 @@ export default class BookParser { return {fb2}; } + imageHrefToId(id) { + let local = false; + if (id[0] == '#') { + id = id.substr(1); + local = true; + } + return {id, local}; + } + findParaIndex(bookPos) { let result = undefined; //дихотомия @@ -562,28 +571,19 @@ export default class BookParser { case 'image': { let attrs = sax.getAttrsSync(tail); if (attrs.href && attrs.href.value) { - let id = attrs.href.value; - let local = false; - if (id[0] == '#') { - id = id.substr(1); - local = true; - } - image = {local, inline: false, id}; + image = this.imageHrefToId(attrs.href.value); + image.inline = false; } break; } case 'image-inline': { let attrs = sax.getAttrsSync(tail); if (attrs.href && attrs.href.value) { - let id = attrs.href.value; - let local = false; - if (id[0] == '#') { - id = id.substr(1); - local = true; - } + const img = this.imageHrefToId(attrs.href.value); + img.inline = true; result.push({ style: Object.assign({}, style), - image: {local, inline: true, id}, + image: img, text: '' }); }