Try using "Template" action and construct your text with hyerlinks than paste it to page.
Other option is to create simple LOCAL html page somewhere on your hard disk with
desired text and links, than open that local html page in another tab in BAS and than copy
from that tab to the tab where you are working.
Как в списке удалить весь текст выше 3-рёх подряд строк заканчивающихся на знаки препинания в конце?
-
Есть переменная [[LIST_WITH_FILE_CONTENT]] в ней много строчек.
Подскажите, как с помощью JS удалить в нём все строки что выше 3-рёх подряд идущих строк.
В конце этих 3-рёх строк должны стоять символы из списка [[SYMBOLS]] .
В списке [[SYMBOLS]] находятся знаки препинания:
. , ! ? " ' : ” “Пример [[LIST_WITH_FILE_CONTENT]] :
Or to take arms against a sea of troubles? And by opposing end them. To die—to sleep No more; and by a sleep to say we end. The heart-ache and the thousand natural shocks That flesh is heir to: ’tis a consummation! Devoutly to be wish’d. To die, to sleep; To sleep, perchance to dream—ay, there’s the rub: For in that sleep of death what dreams may come Borne on the bier6 with white and bristly beard: Then of thy beauty do I question makeДолжно остаться так (выделил красной рамкой):

Написал JS-код для экшена Яваскрипт:const str = [[LIST_WITH_FILE_CONTENT]]; const punct = [[SYMBOLS]]; const numStrWithPunctEnd = 3; const arr = str.split('\n'); const index = arr.findIndex(function(n, i, a) { return this.every(m => punct.includes(a[i + m].slice(-1))); }, [...Array(numStrWithPunctEnd).keys()]); const result = index !== -1 ? arr.slice(index).join('\n') : str; [[LIST_WITH_FILE_CONTENT]]=result;Но почему выдаёт ошибку:

-
@Nikolas said in Как в списке удалить весь текст выше 3-рёх подряд строк заканчивающихся на знаки препинания в конце?:
Есть переменная [[LIST_WITH_FILE_CONTENT]] в ней много строчек.
Подскажите, как с помощью JS удалить в нём все строки что выше 3-рёх подряд идущих строк.Скажите, для чего вы каждую задачу пытаетесь решить через js скрипты не разбираясь в них совсем? Чем вам кубики BAS'a не угодили?
-
Вот готовый код, может кому-то будет полезно.
Переменные [[LIST_WITH_FILE_CONTENT]]
и [[SYMBOLS]] естественно до этого должны быть заданы.Код закидываем в экшен Яваскрипт:
let arr = [[LIST_WITH_FILE_CONTENT]]; const punct = [[SYMBOLS]]; const numStrWithPunctEnd = 3; const index = arr.findIndex(function(n, i, a) { return this.every(m => punct.includes(a[i + m].slice(-1))); }, [...Array(numStrWithPunctEnd).keys()]); const result = index !== -1 ? arr.slice(index).join('\n') : arr; [[LIST_WITH_FILE_CONTENT]]=result;Получаем результат в виде строки в переменной [[LIST_WITH_FILE_CONTENT]].
Далее , пишем данные из [[LIST_WITH_FILE_CONTENT]] в файл с помощью экшена Запись в файл-> далее следующим экшеном -> Читать файл в список. Таким образом получаем готовый результат уже в виде списка в переменной [[LIST_WITH_FILE_CONTENT]]