Methods and apparatus are provided for assisting a user who is editing a markup document on a computer. The user is presented with the markup document on a display of the computer for editing and provided with grammatical assistance based on a grammar inferred from current content of the markup document. The grammar may be inferred and updated automatically after the markup document is loaded or edited. The assistance provided may be based on a combination of an inferred grammar and a real grammar. The markup document can be an extensible markup language (XML) document.