Created
April 17, 2014 13:00
-
-
Save mox601/10981608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://webapps.stackexchange.com/questions/23861/header-numbering-in-google-docs */ | |
var pars = DocumentApp.getActiveDocument().getBody().getParagraphs(); | |
for(var i=0; i<pars.length; i++) { | |
var par = pars[i]; | |
var hdg = par.getHeading(); | |
if (hdg == DocumentApp.ParagraphHeading.HEADING1) { | |
counterh1 = counterh1+1; counterh2 = 0; counterh3 = 0; counterh4 = 0; counterh5 = 0; counterh6 = 0; | |
var content = par.getText(); | |
var chunks = content.split('\t') | |
var result = 'ok' | |
if(chunks.length > 1) { par.setText(counterh1+'.\t'+chunks[1]); } | |
else { par.setText(counterh1+'.\t'+chunks[0]); } | |
} | |
... idem for HEADING2,3,4,5,6 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment