import fs from 'fs'
import path from 'path'
import os from 'os'

const x = fs.readFileSync(path.join(os.tmpdir(), 'gis-doc-raw.xml'), 'utf8')

function snippet(k, len = 1800) {
  const i = x.indexOf(k)
  if (i < 0) return `${k}: NOT FOUND`
  return x
    .slice(Math.max(0, i - 200), i + len)
    .replace(/&lt;/g, '<')
    .replace(/&gt;/g, '>')
    .replace(/&quot;/g, '"')
    .replace(/<w:tab[^>]*\/>/g, ' ')
    .replace(/<\/w:p>/g, '\n')
    .replace(/<[^>]+>/g, '')
}

const keys = [
  'cmmap-gl.js',
  'cmmap-gl.css',
  'cmmapgl.accessToken',
  '地图密钥',
  '地图组件',
  'script src',
  'style:',
  'agis/resources'
]

for (const k of keys) {
  console.log('\n========', k, '========\n')
  console.log(snippet(k))
}
