I don't think that is possible. Pushdown automata can recognize precisely context-free languages. But think about how a pushdown automaton would have to operate to decide the level of a heading in your example.
A pushdown automaton has a finite set of states. So it cannot use the states to track the level of a heading if we are to allow arbirtarily deep levels. So it must use its stack. The only way to count using the stack is to push a stack symbol (there are a finite number of stack symbols too) each time it reads a *
. Say it is somewhere in the input string at the beginning of some *
s. It proceeds by pushing a stack symbol for every *
. But when it comes to the end of the *
s in the input string, the only things the automaton can use to decide its action are: the symbol in the input string, its state, and the top symbol on the stack. We "already" knew that the input symbol is not a *
, so that does not help. We know that the top of the stack is the symbol that we pushed once for every *
, so that does not help either. And as previously noted, the set of states are finite, so we can not somehow use the states to count the number of symbols on the stack.