Okuyun / Kuran

https://okuyun.github.io/Kuran/
6 stars 3 forks source link

get HTML data from reader #36

Open maeyler opened 1 year ago

maeyler commented 1 year ago

Problem: extract several verses from a given chapter, with the root of each word in data tag

Solution: https://github.com/Okuyun/Kitap/blob/main/ders/huruf.html

  1. open https://okuyun.github.io/Kuran/reader
  2. define the snippets below
  3. run chapToHTML(2, 4) // get from chapter 2 the first 4 verses
    // c: chapter [1-114], n: number of verses
    chapToHTML = (c,n) => { 
    let i = indexOf(c,1)
    let s = Q.qur.data.slice(i,i+n).map(verseToHTML).join('*\n')
    console.log(header(c)+s+'<br>\n')
    }
    header = c => `  <tr>
    <td>
    <a class=sure href="/Kuran/reader.html#v=${c}:1" target="iqra">${c} ${suraNames.tr[c]}</a>
    <span data="harf"></span> 
    <td class=ayet>
    <a class=sure href="/Kuran/reader.html#v=${c}:1" target="iqra">${suraNames.ar[c]}</a>
    <span data="harf"></span> `
    verseToHTML = s => s.split(' ').slice(1).map(wordToHTML).join(' ')
    wordToHTML = x => {
    let r = Q.roots.wordToRoot(toBuckwalter(x));
    return r? '<span data='+r+'>'+x+'</span>': x
    }
maeyler commented 1 year ago

This is not a real issue -- just a litlle note to myself

I need this snippet often, that's why I placed in an issue