Linguistics is a notoriously divided field and it's unsurprising if people do not agree on these terms (and grammar can be a particularly loose term -- I think lemontree gets at that in the answer you link!). What one includes in one's definition of grammar depends on the theoretical framework one subscribes to and how one views language. By way of example, let me briefly lay out the Cognitive Grammar view, probably largely agreeable to linguists taking a usage-based approach to language.
Langacker (1987: 57) talks about grammar as the "psychological representation of the linguistic system" and characterizes this as "those aspects of cognitive organization in which resides a speaker's grasp of established linguistic convention" (p. 57) / "a speaker's knowledge of linguistic convention" (p. 36) / "a structured inventory of conventional linguistic units" (p. 57).
For an idea of what is included in this view of grammar and how it might differ from other views, we have this quotation:
"Contemporary linguistic theory generally views language as being
organized into discrete components. In particular, syntax is seen as
sharply distinct from both lexicon and semantics, constituting an
autonomous set of formal relationships. Cognitive grammar, by
contrast, claims that lexicon, morphology, and syntax form a continuum
of symbolic units [i.e., form-meaning pairings] serving to structure conceptual content. It is
incoherent in this view to speak of grammar in isolation from meaning,
and the segmentation of grammatical structure into discrete components
is rejected." (pp. 34-5)
Where some linguists view grammar as a purely formal system, here grammar is inherently bound up with meaning. Where some linguists sharply distinguish between 'syntax, morphology and lexicon' (such linguists might even say 'grammar and lexicon'), here they form a gradation which can be distinguished only arbitrarily.
So the point that I want to get across is that there is no one definitive, correct answer to the question 'What is the definition of grammar?' or 'What is included in grammar?'. It comes down to the framework one works within and how one views language.
- Langacker, Ronald W. (1987). Foundations of Cognitive Grammar (vol.
1): Theoretical Prerequisites. Stanford UP.