Nelson Tolentino, 44, of South San Francisco was arrested and is being charged with willful injury to a child and attempted murder for his role in the attack, according to the San Mateo County Sheriff's Department.

Tolentino approached a 13-year-old standing outside the library, brandished a four-inch folding knife and began attacking the teen, according to sheriff's officials.

The teen managed to escape Tolentino's grasp and run inside the library for shelter, according to the sheriff's department. He suffered injuries to both of his arms, but he is expected to recover.