| 12345678910111213141516171819202122232425262728293031323334353637 |
- import fs from 'fs'
- import os from 'os'
- import path from 'path'
- const xmlPath = path.join(os.tmpdir(), 'gis-doc-raw.xml')
- const x = fs.readFileSync(xmlPath, 'utf8')
- function strip(chunk) {
- return chunk
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/&/g, '&')
- .replace(/<w:tab[^>]*\/>/g, '\t')
- .replace(/<\/w:p>/g, '\n')
- .replace(/<[^>]+>/g, '')
- .replace(/\n{3,}/g, '\n\n')
- }
- const text = strip(x)
- const keys = ['周边', '2.2', 'longitude', 'latitude', 'radius', 'page_size', 'pageSize', 'POI', '搜索', 'nearby', 'agis']
- for (const k of keys) {
- const i = text.indexOf(k)
- if (i >= 0) {
- console.log(`\n######## ${k} @ ${i} ########`)
- console.log(text.slice(Math.max(0, i - 150), i + 1200))
- }
- }
- // dump section around "2.2"
- const i22 = text.indexOf('2.2')
- if (i22 >= 0) {
- console.log('\n######## FULL 2.2 SECTION ########')
- console.log(text.slice(i22, i22 + 4000))
- }
|